Merge remote-tracking branch 'upstream/master'

Update the fork repository from source by Shell command.
This commit is contained in:
stevenzdg988 2021-03-16 07:40:16 +08:00
commit a2b7d79b2b
4 changed files with 290 additions and 335 deletions

View File

@ -0,0 +1,232 @@
[#]: collector: (lujun9972)
[#]: translator: (stevenzdg988)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-13206-1.html)
[#]: subject: (9 favorite open source tools for Node.js developers)
[#]: via: (https://opensource.com/article/20/1/open-source-tools-nodejs)
[#]: author: (Hiren Dhadhuk https://opensource.com/users/hirendhadhuk)
9 个 Node.js 开发人员最喜欢的开源工具
======
> 在众多可用于简化 Node.js 开发的工具中,以下 9 种是最佳选择。
![](https://img.linux.net.cn/data/attachment/album/202103/15/233658i99wxvzin13o5319.png)
我最近在 [StackOverflow][2] 上读到了一项调查,该调查称超过 49 的开发人员在其项目中使用了 Node.js。这结果对我来说并不意外。
作为一个狂热的技术使用者,我可以肯定地说 Node.js 的引入引领了软件开发的新时代。现在它是软件开发最受欢迎的技术之一仅次于JavaScript。
### Node.js 是什么,为什么如此受欢迎?
Node.js 是一个跨平台的开源运行环境,用于在浏览器之外执行 JavaScript 代码。它也是建立在 Chrome 的 JavaScript 运行时之上的首选运行时环境,主要用于构建快速、可扩展和高效的网络应用程序。
我记得当时我们要花费几个小时来协调前端和后端开发人员,他们分别编写不同脚本。当 Node.js 出现后,所有这些都改变了。我相信,促使开发人员采用这项技术是因为它的双向效率。
使用 Node.js你可以让你的代码同时运行在客户端和服务器端从而加快了整个开发过程。Node.js 弥合了前端和后端开发之间的差距,并使开发过程更加高效。
### Node.js 工具浪潮
对于 49 的开发人员包括我来说Node.js 处于在前端和后端开发的金字塔顶端。有大量的 [Node.js 用例][3] 帮助我和我的团队在截止日期之内交付复杂的项目。幸运的是Node.js 的日益普及也产生了一系列开源项目和工具,以帮助开发人员使用该环境。
近来,对使用 Node.js 构建的项目的需求突然增加。有时,我发现管理这些项目,并同时保持交付高质量项目的步伐非常具有挑战性。因此,我决定使用为 Node.js 开发人员提供的许多开源工具中一些最高效的,使某些方面的开发自动化。
根据我在 Node.js 方面的丰富经验,我使用了许多的工具,这些工具对整个开发过程都非常有帮助:从简化编码过程,到监测再到内容管理。
为了帮助我的 Node.js 开发同道,我整理了这个列表,其中包括我最喜欢的 9 个简化 Node.js 开发的开源工具。
### Webpack
[Webpack][4] 是一个容易使用的 JavaScript <ruby>模块捆绑程序<rt>module bundler</rt></ruby>,用于简化前端开发。它会检测具有依赖的模块,并将其转换为描述模块的静态<ruby>素材<rt>asset</rt></ruby>
可以通过软件包管理器 npm 或 Yarn 安装该工具。
利用 npm 命令安装如下:
```
npm install --save-dev webpack
```
利用 Yarn 命令安装如下:
```
yarn add webpack --dev
```
Webpack 可以创建在运行时异步加载的单个捆绑包或多个素材链。不必单独加载。使用 Webpack 工具可以快速高效地打包这些素材并提供服务,从而改善用户整体体验,并减少开发人员在管理加载时间方面的困难。
### Strapi
[Strapi][5] 是一个开源的<ruby>无界面<rt>headless</rt></ruby>内容管理系统CMS。无界面 CMS 是一种基础软件,可以管理内容而无需预先构建好的前端。它是一个使用 RESTful API 函数的只有后端的系统。
可以通过软件包管理器 Yarn 或 npx 安装 Strapi。
利用 Yarn 命令安装如下:
```
yarn create strapi-app my-project --quickstart
```
利用 npx 命令安装如下:
```
npx create-strapi-app my-project --quickstart
```
Strapi 的目标是在任何设备上以结构化的方式获取和交付内容。CMS 可以使你轻松管理应用程序的内容,并确保它们是动态的,可以在任何设备上访问。
它提供了许多功能包括文件上传、内置的电子邮件系统、JSON Web TokenJWT验证和自动生成文档。我发现它非常方便因为它简化了整个 CMS并为我提供了编辑、创建或删除所有类型内容的完全自主权。
另外,通过 Strapi 构建的内容结构非常灵活,因为你可以创建和重用内容组和可定制的 API。
### Broccoli
[Broccoli][6] 是一个功能强大的构建工具,运行在 [ES6][7] 模块上。构建工具是一种软件可让你将应用程序或网站中的所有各种素材例如图像、CSS、JavaScript 等组合成一种可分发的格式。Broccoli 将自己称为 “雄心勃勃的应用程序的素材管道”。
使用 Broccoli 你需要一个项目目录。有了项目目录后,可以使用以下命令通过 npm 安装 Broccoli
```
npm install --save-dev broccoli
npm install --global broccoli-cli
```
你也可以使用 Yarn 进行安装。
当前版本的 Node.js 就是使用该工具的最佳版本,因为它提供了长期支持。它可以帮助你避免进行更新和重新安装过程中的麻烦。安装过程完成后,可以在 `Brocfile.js` 文件中包含构建规范。
在 Broccoli 中,抽象单位是“树”,该树将文件和子目录存储在特定子目录中。因此,在构建之前,你必须有一个具体的想法,你希望你的构建是什么样子的。
最好的是Broccoli 带有用于开发的内置服务器,可让你将素材托管在本地 HTTP 服务器上。Broccoli 非常适合流线型重建因为其简洁的架构和灵活的生态系统可提高重建和编译速度。Broccoli 可让你井井有条,以节省时间并在开发过程中最大限度地提高生产力。
### Danger
[Danger][8] 是一个非常方便的开源工具,用于简化你的<ruby>拉取请求<rt>pull request</rt></ruby>PR检查。正如 Danger 库描述所说,该工具可通过管理 PR 检查来帮助 “正规化” 你的代码审查系统。Danger 可以与你的 CI 集成在一起,帮助你加快审核过程。
将 Danger 与你的项目集成是一个简单的逐步过程:你只需要包括 Danger 模块,并为每个项目创建一个 Danger 文件。然而,创建一个 Danger 帐户(通过 GitHub 或 Bitbucket 很容易做到),并且为开源软件项目设置访问令牌更加方便。
可以通过 NPM 或 Yarn 安装 Danger。要使用 Yarn请添加 `danger -D``package.JSON` 中。
将 Danger 添加到 CI 后,你可以:
* 高亮显示重要的创建工件
* 通过强制链接到 Trello 和 Jira 之类的工具来管理 sprint
* 强制生成更新日志
* 使用描述性标签
* 以及更多
例如,你可以设计一个定义团队文化并为代码审查和 PR 检查设定特定规则的系统。根据 Danger 提供的元数据及其广泛的插件生态系统,可以解决常见的<ruby>议题<rt>issue</rt></ruby>
### Snyk
网络安全是开发人员的主要关注点。[Snyk][9] 是修复开源组件中漏洞的最著名工具之一。它最初是一个用于修复 Node.js 项目漏洞的项目,并且已经演变为可以检测并修复 Ruby、Java、Python 和 Scala 应用程序中的漏洞。Snyk 主要分四个阶段运行:
* 查找漏洞依赖性
* 修复特定漏洞
* 通过 PR 检查预防安全风险
* 持续监控应用程序
Snyk 可以集成在项目的任何阶段包括编码、CI/CD 和报告。我发现这对于测试 Node.js 项目非常有帮助,可以测试或构建 npm 软件包时检查是否存在安全风险。你还可以在 GitHub 中为你的应用程序运行 PR 检查以使你的项目更安全。Synx 还提供了一系列集成,可用于监控依赖关系并解决特定问题。
要在本地计算机上运行 Snyk可以通过 NPM 安装它:
```
npm install -g snyk
```
### Migrat
[Migrat][10] 是一款使用纯文本的数据迁移工具,非常易于使用。 它可在各种软件堆栈和进程中工作,从而使其更加实用。你可以使用简单的代码行安装 Migrat
```
$ npm install -g migrat
```
Migrat 并不需要特别的数据库引擎。它支持多节点环境因为迁移可以在一个全局节点上运行也可以在每个服务器上运行一次。Migrat 之所以方便,是因为它便于向每个迁移传递上下文。
你可以定义每个迁移的用途例如数据库集、连接、日志接口等。此外为了避免随意迁移即多个服务器在全局范围内进行迁移Migrat 可以在进程运行时进行全局锁定,从而使其只能在全局范围内运行一次。它还附带了一系列用于 SQL 数据库、Slack、HipChat 和 Datadog 仪表盘的插件。你可以将实时迁移状况发送到这些平台中的任何一个。
### Clinic.js
[Clinic.js][11] 是一个用于 Node.js 项目的开源监视工具。它结合了三种不同的工具 Doctor、Bubbleprof 和 Flame帮助你监控、检测和解决 Node.js 的性能问题。
你可以通过运行以下命令从 npm 安装 Clinic.js
```
$ npm install clinic
```
你可以根据要监视项目的某个方面以及要生成的报告,选择要使用的 Clinic.js 包含的三个工具中的一个:
* Doctor 通过注入探针来提供详细的指标,并就项目的总体运行状况提供建议。
* Bubbleprof 非常适合分析,并使用 `async_hooks` 生成指标。
* Flame 非常适合发现代码中的热路径和瓶颈。
### PM2
监视是后端开发过程中最重要的方面之一。[PM2][12] 是一款 Node.js 的进程管理工具,可帮助开发人员监视项目的多个方面,例如日志、延迟和速度。该工具与 Linux、MacOS 和 Windows 兼容,并支持从 Node.js 8.X 开始的所有 Node.js 版本。
你可以使用以下命令通过 npm 安装 PM2
```
$ npm install pm2 --g
```
如果尚未安装 Node.js则可以使用以下命令安装
```
wget -qO- https://getpm2.com/install.sh | bash
```
安装完成后,使用以下命令启动应用程序:
```
$ pm2 start app.js
```
关于 PM2 最好的地方是可以在集群模式下运行应用程序。可以同时为多个 CPU 内核生成一个进程。这样可以轻松增强应用程序性能并最大程度地提高可靠性。PM2 也非常适合更新工作,因为你可以使用 “热重载” 选项更新应用程序并以零停机时间重新加载应用程序。总体而言,它是为 Node.js 应用程序简化进程管理的好工具。
### Electrode
[Electrode][13] 是 Walmart Labs 的一个开源应用程序平台。该平台可帮助你以结构化方式构建大规模通用的 React/Node.js 应用程序。
Electrode 应用程序生成器使你可以构建专注于代码的灵活内核,提供一些出色的模块以向应用程序添加复杂功能,并附带了广泛的工具来优化应用程序的 Node.js 包。
可以使用 npm 安装 Electrode。安装完成后你可以使用 Ignite 启动应用程序,并深入研究 Electrode 应用程序生成器。
你可以使用 NPM 安装 Electrode
```
npm install -g electrode-ignite xclap-cli
```
### 你最喜欢哪一个?
这些只是不断增长的开源工具列表中的一小部分,在使用 Node.js 时,这些工具可以在不同阶段派上用场。你最喜欢使用哪些开源 Node.js 工具?请在评论中分享你的建议。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/1/open-source-tools-nodejs
作者:[Hiren Dhadhuk][a]
选题:[lujun9972][b]
译者:[stevenzdg988](https://github.com/stevenzdg988)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/hirendhadhuk
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_hardware_purple.png?itok=3NdVoYhl (Tools illustration)
[2]: https://insights.stackoverflow.com/survey/2019#technology-_-other-frameworks-libraries-and-tools
[3]: https://www.simform.com/nodejs-use-case/
[4]: https://webpack.js.org/
[5]: https://strapi.io/
[6]: https://broccoli.build/
[7]: https://en.wikipedia.org/wiki/ECMAScript#6th_Edition_-_ECMAScript_2015
[8]: https://danger.systems/
[9]: https://snyk.io/
[10]: https://github.com/naturalatlas/migrat
[11]: https://clinicjs.org/
[12]: https://pm2.keymetrics.io/
[13]: https://www.electrode.io/

View File

@ -3,16 +3,16 @@
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-13205-1.html)
在 Linux 上使用 gImageReader 从图像和 PDF 中提取文本
======
_简介gImageReader 是一个 GUI 工具,用于在 Linux 中利用 Tesseract OCR 引擎从图像和 PDF 文件中提取文本。_
> gImageReader 是一个 GUI 工具,用于在 Linux 中利用 Tesseract OCR 引擎从图像和 PDF 文件中提取文本。
[gImageReader][1] 是 [Tesseract 开源 OCR 引擎][2]的一个前端。_Tesseract_ 最初是由 HP 公司开发的,然后在 2006 年开源。
[gImageReader][1] 是 [Tesseract 开源 OCR 引擎][2]的一个前端。Tesseract 最初是由 HP 公司开发的,然后在 2006 年开源。
基本上OCR光学字符识别引擎可以让你从图片或文件PDF中扫描文本。默认情况下它可以检测几种语言还支持通过 Unicode 字符扫描。
@ -28,7 +28,7 @@ _简介gImageReader 是一个 GUI 工具,用于在 Linux 中利用 Tesserac
无论你是需要它来进行拼写检查还是翻译,它都应该对特定的用户群体有用。
列表总结下功能,这里是你可以用它做的事情:
列表总结下功能,这里是你可以用它做的事情:
* 从磁盘、扫描设备、剪贴板和截图中添加 PDF 文档和图像
* 能够旋转图像
@ -43,11 +43,9 @@ _简介gImageReader 是一个 GUI 工具,用于在 Linux 中利用 Tesserac
* 将提取的文本导出为 .txt 文件
* 跨平台Windows
### 在 Linux 上安装 gImageReader
**注意**_你需要安装 Tesseract 语言包,才能从软件管理器中的图像/文件中进行检测。_
**注意**:你需要安装 Tesseract 语言包,才能从软件管理器中的图像/文件中进行检测。
![][5]
@ -65,8 +63,6 @@ sudo apt install gimagereader
所有的仓库和包的链接都可以在他们的 [GitHub 页面][1]中找到。
[gImageReader][1]
### gImageReader 使用经验
当你需要从图像中提取文本时gImageReader 是一个相当有用的工具。当你尝试从 PDF 文件中提取文本时,它的效果非常好。
@ -90,7 +86,7 @@ via: https://itsfoss.com/gimagereader-ocr/
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,249 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (stevenzdg988)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (9 favorite open source tools for Node.js developers)
[#]: via: (https://opensource.com/article/20/1/open-source-tools-nodejs)
[#]: author: (Hiren Dhadhuk https://opensource.com/users/hirendhadhuk)
9 favorite open source tools for Node.js developers
======
Of the wide range of tools available to simplify Node.js development,
here are the 10 best.
![Tools illustration][1]
I recently read a survey on [StackOverflow][2] that said more than 49% of developers use Node.js for their projects. This came as no surprise to me.
As an avid user of technology, I think it's safe to say that the introduction of Node.js led to a new era of software development. It is now one of the most preferred technologies for software development, right next to JavaScript.
### What is Node.js, and why is it so popular?
Node.js is a cross-platform, open source runtime environment for executing JavaScript code outside of the browser. It is also a preferred runtime environment built on Chrome's JavaScript runtime and is mainly used for building fast, scalable, and efficient network applications.
I remember when we used to sit for hours and hours coordinating between front-end and back-end developers who were writing different scripts for each side. All of this changed as soon as Node.js came into the picture. I believe that the one thing that drives developers towards this technology is its two-way efficiency.
With Node.js, you can run your code simultaneously on both the client and the server side, speeding up the whole process of development. Node.js bridges the gap between front-end and back-end development and makes the development process much more efficient.
### A wave of Node.js tools
For 49% of all developers (including me), Node.js is at the top of the pyramid when it comes to front-end and back-end development. There are tons of [Node.js use cases][3] that have helped me and my team deliver complex projects within our deadlines. Fortunately, Node.js' rising popularity has also produced a wave of open source projects and tools to help developers working with the environment.
Recently, there has been a sudden increase in demand for projects built with Node.js. Sometimes, I find it quite challenging to manage these projects and keep up the pace while delivering high-quality results. So I decided to automate certain aspects of development using some of the most efficient of the many open source tools available for Node.js developers.
In my extensive experience with Node.js, I've worked with a wide range of tools that have helped me with the overall development process—from streamlining the coding process to monitoring to content management.
To help my fellow Node.js developers, I compiled this list of 9 of my favorite open source tools for simplifying Node.js development.
### Webpack
[Webpack][4] is a handy JavaScript module bundler used to simplify front-end development. It detects modules with dependencies and transforms them into static assets that represent the modules.
You can install the tool through either the npm or Yarn package manager.
With npm:
```
`npm install --save-dev webpack`
```
With Yarn:
```
`yarn add webpack --dev`
```
Webpack creates single bundles or multiple chains of assets that can be loaded asynchronously at runtime. Each asset does not have to be loaded individually. Bundling and serving assets becomes quick and efficient with the Webpack tool, making the overall user experience better and reducing the developer's hassle in managing load time.
### Strapi
[Strapi][5] is an open source headless content management system (CMS). A headless CMS is basically software that lets you manage your content devoid of a prebuilt frontend. It is a backend-only system that functions using RESTful APIs.
You can install Strapi through Yarn or npx packages.
With Yarn:
```
`yarn create strapi-app my-project --quickstart`
```
With npx:
```
`npx create-strapi-app my-project --quickstart`
```
Strapi's goal is to fetch and deliver your content in a structured manner across any device. The CMS makes it easy to manage your applications' content and make sure they are dynamic and accessible across any device.
It provides a lot of features, including file upload, a built-in email system, JSON Web Token (JWT) authentication, and auto-generated documentation. I find it very convenient, as it simplifies the overall CMS and gives me full autonomy in editing, creating, or deleting all types of contents.
In addition, the content structure built through Strapi is extremely flexible because you can create and reuse groups of content and customizable APIs.
### Broccoli
[Broccoli][6] is a powerful build tool that runs on an [ES6][7] module. Build tools are software that let you assemble all the different assets within your application or website, e.g., images, CSS, JavaScript, etc., into one distributable format. Broccoli brands itself as the "asset pipeline for ambitious applications."
You need a project directory to work with Broccoli. Once you have the project directory in place, you can install Broccoli with npm using:
```
npm install --save-dev broccoli
npm install --global broccoli-cli
```
You can also use Yarn for installation. 
The current version of Node.js would be the best version for the tool as it provides long-time support. This helps you avoid the hassle of updating and reinstalling as you go. Once the installation process is completed, you can include the build specification in your Brocfile.js.
In Broccoli, the unit of abstraction is a tree, which stores files and subdirectories within specific subdirectories. Therefore, before you build, you must have a specific idea of what you want your build to look like.
The best part about Broccoli is that it comes with a built-in server for development that lets you host your assets on a local HTTP server. Broccoli is great for streamlined rebuilds, as its concise architecture and flexible ecosystem boost rebuild and compilation speeds. Broccoli lets you get organized to save time and maximize productivity during development.
### Danger
[Danger][8] is a very handy open source tool for streamlining your pull request (PR) checks. As Danger's library description says, the tool helps you "formalize" your code review system by managing PR checks. Danger integrates with your CI and helps you speed up the review process.
Integrating Danger with your project is an easy step-by-step process—you just need to include the Danger module and create a Danger file for each project. However, it's more convenient to create a Danger account (easy to do through GitHub or Bitbucket), then set up access tokens for your open source software projects.
Danger can be installed via NPM or Yarn. To use Yarn, add danger -D to add it to your package.JSON.
After you add Danger to your CI, you can:
* Highlight build artifacts of importance
* Manage sprints by enforcing links to tools like Trello and Jira
* Enforce changelogs
* Utilize descriptive labels
* And much more
For example, you can design a system that defines the team culture and sets out specific rules for code review and PR checks. Common issues can be solved based on the metadata Danger provides along with its extensive plugin ecosystem.
### Snyk
Cybersecurity is a major concern for developers. [Snyk][9] is one of the most well-known tools to fix vulnerabilities in open source components. It started as a project to fix vulnerabilities in Node.js projects and has evolved to detect and fix vulnerabilities in Ruby, Java, Python, and Scala apps as well. Snyk mainly runs in four stages:
* Finding vulnerability dependencies
* Fixing specific vulnerabilities
* Preventing security risks by PR checks
* Monitoring apps continuously
Snyk can be integrated with your project at any stage, including coding, CI/CD, and reporting. I find it extremely helpful for testing Node.js projects to test out npm packages for security risks or at build-time. You can also run PR checks for your applications in GitHub to make your projects more secure. Synx also provides a range of integrations that you can use to monitor dependencies and fix specific problems.
To run Snyk on your machine locally, you can install it through NPM:
```
`npm install -g snyk`
```
### Migrat
[Migrat][10] is an extremely easy to use data-migration tool that uses plain text. It works across a diverse range of stacks and processes that make it even more convenient. You can install Migrat with a simple line of code:
```
`$ npm install -g migrat`
```
Migrat is not specific to a particular database engine. It supports multi-node environments, as migrations can run on one node globally or once per server. What makes Migrat convenient is the facilitation of passing context to each migration.
You can define what each migration is for (e.g.,. database sets, connections, logging interfaces, etc.). Moreover, to avoid haphazard migrations, where multiple servers are running migrations globally, Migrat facilitates global lockdown while the process is running so that it can run only once globally. It also comes with a range of plug-ins for SQL databases, Slack, HipChat, and the Datadog dashboard. You can send live migrations to any of these platforms.
### Clinic.js
[Clinic.js][11] is an open source monitoring tool for Node.js projects. It combines three different tools—Doctor, Bubbleprof, and Flame—that help you monitor, detect, and solve performance issues with Node.js.
You can install Clinic.js from npm by running this command:
```
`$ npm install clinic`
```
You can choose which of the three tools that comprise Clinic.js you want to use based on which aspect of your project you want to monitor and the report you want to generate:
* Doctor provides detailed metrics by injecting probes and provides recommendations on the overall health of your project.
* Bubbleprof is great for profiling and generates metrics using async_hooks.
* Flame is great for uncovering hot paths and bottlenecks in your code.
### PM2
Monitoring is one of the most important aspects of any backend development process. [PM2][12] is a process management tool for Node.js that helps developers monitor multiple aspects of their projects such as logs, delays, and speed. The tool is compatible with Linux, MacOS, and Windows and supports all Node.js versions starting from Node.js 8.X.
You can install PM2 with npm using:
```
`$ npm install pm2 --g`
```
If you do not already have Node.js installed, you can use:
```
`wget -qO- https://getpm2.com/install.sh | bash`
```
Once it's installed, start the application with:
```
`$ pm2 start app.js`
```
The best part about PM2 is that it lets you run your apps in cluster mode. You can spawn a process for multiple CPU cores at a time. This makes it easy to enhance application performance and maximize reliability. PM2 is also great for updates, as you can update your apps and reload them with zero downtime using the "hot reload" option. Overall, it's a great tool to simplify process management for Node.js applications.
### Electrode
[Electrode][13] is an open source application platform from Walmart Labs. The platform helps you build large-scale, universal React/Node.js applications in a structured manner.
The Electrode app generator lets you build a flexible core focused on the code, provides some great modules to add complex features to the app, and comes with a wide range of tools to optimize your app's Node.js bundle.
Electrode can be installed using npm. Once the installation is finished, you can start the app using Ignite and dive right in with the Electrode app generator.
You can install Electrode using NPM:
```
`npm install -g electrode-ignite xclap-cli`
```
### Which are your favorite?
These are just a few of the always-growing list of open source tools that can come in handy at different stages when working with Node.js. Which are your go-to open source Node.js tools? Please share your recommendations in the comments.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/1/open-source-tools-nodejs
作者:[Hiren Dhadhuk][a]
选题:[lujun9972][b]
译者:[stevenzdg988](https://github.com/stevenzdg988)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/hirendhadhuk
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_hardware_purple.png?itok=3NdVoYhl (Tools illustration)
[2]: https://insights.stackoverflow.com/survey/2019#technology-_-other-frameworks-libraries-and-tools
[3]: https://www.simform.com/nodejs-use-case/
[4]: https://webpack.js.org/
[5]: https://strapi.io/
[6]: https://broccoli.build/
[7]: https://en.wikipedia.org/wiki/ECMAScript#6th_Edition_-_ECMAScript_2015
[8]: https://danger.systems/
[9]: https://snyk.io/
[10]: https://github.com/naturalatlas/migrat
[11]: https://clinicjs.org/
[12]: https://pm2.keymetrics.io/
[13]: https://www.electrode.io/

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (stevenzdg988)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
@ -7,22 +7,20 @@
[#]: via: (https://opensource.com/article/20/9/calendar-jupyter)
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
Improve your time management with Jupyter
使用 Jupyter 改善你的时间管理
======
Discover how you are spending time by parsing your calendar with Python
in Jupyter.
![Calendar close up snapshot][1]
通过在 Jupyter 里使用 Python 分析日历了解您如何使用时间 。
![日历特写快照][1]
[Python][2] has incredibly scalable options for exploring data. With [Pandas][3] or [Dask][4], you can scale [Jupyter][5] up to big data. But what about small data? Personal data? Private data?
[Python][2] 在用于探索数据方面具有令人难以置信的可扩展性选项。利用 [Pandas][3] 或 [Dask][4],您可以将 [Jupyter][5] 扩展到大数据(处理)。但是小数据呢?个人资料?私人数据?
JupyterLab and Jupyter Notebook provide a great environment to scrutinize my laptop-based life.
JupyterLab 和 Jupyter Notebook 提供了一个绝佳的环境来仔细检查我基于笔记本电脑的生活。
My exploration is powered by the fact that almost every service I use has a web application programming interface (API). I use many such services: a to-do list, a time tracker, a habit tracker, and more. But there is one that almost everyone uses: _a calendar_. The same ideas can be applied to other services, but calendars have one cool feature: an open standard that almost all web calendars support: `CalDAV`.
我的探索是基于以下事实:我使用的几乎每个服务都有一个 Web 应用程序编程接口API。我使用了许多此类服务待办事项列表时间跟踪器习惯跟踪器等。但是几乎每个人都使用_日历_。相同的想法可以应用于其他服务但是日历具有一个很酷的功能几乎所有网络日历都支持的开放标准 `CalDAV`
### Parsing your calendar with Python in Jupyter
Most calendars provide a way to export into the `CalDAV` format. You may need some authentication for accessing this private data. Following your service's instructions should do the trick. How you get the credentials depends on your service, but eventually, you should be able to store them in a file. I store mine in my root directory in a file called `.caldav`:
### 在 Jupyter 中使用 Python 解析日历
大多数日历提供了导出为 `CalDAV` 格式的方法。您可能需要某种身份验证才能访问此私有数据。按照您的服务说明进行操作即可。如何获得凭据取决于您的服务,但是最终,您应该能够将它们存储在文件中。我将我的名为 `.caldav` 的文件存储在根(root)目录中:
```
import os
@ -30,26 +28,23 @@ with open(os.path.expanduser("~/.caldav")) as fpin:
    username, password = fpin.read().split()
```
Never put usernames and passwords directly in notebooks! They could easily leak with a stray `git push`.
The next step is to use the convenient PyPI [caldav][6] library. I looked up the CalDAV server for my email service (yours may be different):
切勿将用户名和密码直接放在笔记本中!他们可能会很容易因 `git push` 偏离而导致泄漏。
下一步是使用方便的 PyPI [caldav][6] 库。我在 CalDAV 服务器上查找了我的电子邮件服务(您可能有所不同):
```
import caldav
client = caldav.DAVClient(url="<https://caldav.fastmail.com/dav/>", username=username, password=password)
```
CalDAV has a concept called the `principal`. It is not important to get into right now, except to know it's the thing you use to access the calendars:
CalDAV 有一个称为 `principal`(主键) 的概念。马上进入(该系统)并不重要,除非这是您用于访问日历:
```
principal = client.principal()
calendars = principal.calendars()
```
Calendars are, literally, all about time. Before accessing events, you need to decide on a time range. One week should be a good default:
日历按照字面讲是关于时间的。访问事件之前,您需要确定一个时间范围。默认设置为一星期:
```
from dateutil import tz
@ -58,8 +53,7 @@ now = datetime.datetime.now(tz.tzutc())
since = now - datetime.timedelta(days=7)
```
Most people use more than one calendar, and most people want all their events together. The `itertools.chain.from_iterable` makes this straightforward: ` `
大多数人使用不止一个日历,并且希望所有事件都在一起。`itertools.chain.from_iterable` (方法)使这一过程变得简单:` `
```
import itertools
@ -72,10 +66,9 @@ raw_events = list(
)
```
Reading all the events into memory is important, and doing so in the API's raw, native format is an important practice. This means that when fine-tuning the parsing, analyzing, and displaying code, there is no need to go back to the API service to refresh the data.
But "raw" is not an understatement. The events come through as strings in a specific format:
将所有事件读入内存很重要,以 API 原始的本地格式进行操作是重要的做法。这意味着在调整解析,分析和显示代码时,无需返回到 API 服务刷新数据。
但 “原始” 并不是轻描淡写。事件通过特定格式的字符串实现:
```
`print(raw_events[12].data)`[/code] [code]
@ -96,8 +89,7 @@ But "raw" is not an understatement. The events come through as strings in a spec
    END:VCALENDAR
```
Luckily, PyPI comes to the rescue again with another helper library, [vobject][7]:
幸运的是PyPI 再次使用另一个帮助程序库 [vobject][7] 前来解围:
```
import io
@ -118,10 +110,9 @@ def parse_event(raw_event):
     'uid': [&lt;UID{}1302728i-040000008200E00074C5B7101A82E00800000000D939773EA578D601000000000000000010000000CD71CC3393651B419E9458134FE840F5&gt;]}
```
Well, at least it's a little better.
There is still some work to do to convert it to a reasonable Python object. The first step is to _have_ a reasonable Python object. The [attrs][8] library provides a nice start:
好吧,至少好一点了。
仍有一些工作要做,以将其转换为合理的 Python 对象。第一步是 _拥有_ 一个合理的 Python 对象。[attrs][8] 库提供了一个不错的开始:
```
import attr
@ -134,10 +125,9 @@ class Event:
    summary: str
```
Time to write the conversion code!
The first abstraction gets the value from the parsed dictionary without all the decorations:
是时候编写转换代码了!
第一个抽象在没有所有修饰的情况下从解析字典中获取值:
```
def get_piece(contents, name):
@ -146,8 +136,7 @@ def get_piece(contents, name):
[/code] [code]`get_piece(_, "dtstart")`[/code] [code]`    datetime.datetime(2020, 8, 25, 22, 0, tzinfo=tzutc())`
```
Calendar events always have a start, but they sometimes have an "end" and sometimes a "duration." Some careful parsing logic can harmonize both into the same Python objects:
日历事件总是有一个开始,有一个“结束”,有一个 “持续时间”。一些谨慎的解析逻辑可以将两者协调为同一个 Python 对象:
```
def from_calendar_event_and_timezone(event, timezone):
@ -161,17 +150,15 @@ def from_calendar_event_and_timezone(event, timezone):
    return Event(start=start, end=end, summary=summary, timezone=timezone)
```
Since it is useful to have the events in your _local_ time zone rather than UTC, this uses the local timezone:
由于将事件放在 _本地_ 时区而不是 UTC 中很有用,因此使用本地时区:
```
`my_timezone = tz.gettz()`[/code] [code]`from_calendar_event_and_timezone(raw_events[12], my_timezone)`[/code] [code]`    Event(start=datetime.datetime(2020, 8, 25, 22, 0, tzinfo=tzutc()), end=datetime.datetime(2020, 8, 25, 23, 0, tzinfo=tzutc()), timezone=tzfile('/etc/localtime'), summary='Busy')`
```
Now that the events are real Python objects, they really should have some additional information. Luckily, it is possible to add methods retroactively to classes.
But figuring which _day_ an event happens is not that obvious. You need the day in the _local_ timezone:
既然事件是真实的Python对象那么它们实际上应该具有附加信息。 幸运的是,将方法添加到类中是可能的。
但是弄清楚哪个事件发生在哪一天不是很明显。您需要在 _本地_ 时区中选择一天:
```
def day(self):
@ -183,8 +170,7 @@ Event.day = property(day)
[/code] [code]`print(_.day)`[/code] [code]`    2020-08-25`
```
Events are always represented internally as start/end, but knowing the duration is a useful property. Duration can also be added to the existing class:
事件始终在内部表示为开始/结束,但是知道持续时间是有用的属性。持续时间也可以添加到现有类中:
```
def duration(self):
@ -194,31 +180,27 @@ Event.duration = property(duration)
[/code] [code]`print(_.duration)`[/code] [code]`    1:00:00`
```
Now it is time to convert all events into useful Python objects:
现在到了将所有事件转换为有用的 Python 对象了:
```
all_events = [from_calendar_event_and_timezone(raw_event, my_timezone)
              for raw_event in raw_events]
```
All-day events are a special case and probably less useful for analyzing life. For now, you can ignore them:
全天事件是一种特例,可能对分析生活没有多大用处。现在,您可以忽略它们:
```
# ignore all-day events
all_events = [event for event in all_events if not type(event.start) == datetime.date]
```
Events have a natural order—knowing which one happened first is probably useful for analysis:
事件具有自然顺序——知道哪个事件最先发生可能有助于分析:
```
`all_events.sort(key=lambda ev: ev.start)`
```
Now that the events are sorted, they can be broken into days:
现在,事件已排序,可以将它们加载到每天:
```
import collections
@ -227,14 +209,12 @@ for event in all_events:
    events_by_day[event.day].append(event)
```
And with that, you have calendar events with dates, duration, and sequence as Python objects.
这样,您就可以将带有日期,持续时间和序列的日历事件作为 Python 对象。
### 用 Python 报到你的生活
### Reporting on your life in Python
Now it is time to write reporting code! It is fun to have eye-popping formatting with proper headers, lists, important things in bold, etc.
This means HTML and some HTML templating. I like to use [Chameleon][9]:
现在是时候编写报告代码了!带有适当的标题,列表,重要内容以粗体显示令人惊奇的格式是很有趣的。
这就是 HTML 和 HTML 模板。我喜欢使用 [Chameleon(变色龙:动态的)][9]
```
template_content = """
@ -248,13 +228,10 @@ template_content = """
&lt;/body&gt;&lt;/html&gt;"""
```
One cool feature of Chameleon is that it will render objects using its `html` method. I will use it in two ways:
* The summary will be in **bold**
* For most events, I will remove the summary (since this is my personal information)
Chameleon 的一个很酷的功能是使用 `html` 方法渲染对象。我将以两种方式使用它:
* 摘要将以 **bold** (**粗体**)显示
* 对于大多数活动,我都会删除摘要(因为这是我的个人信息)
```
def __html__(self):
@ -268,8 +245,7 @@ def __html__(self):
Event.__html__ = __html__
```
In the interest of brevity, the report will be sliced into one day's worth.
为了简洁起见,该报告将切成每天的。
```
import chameleon
@ -279,26 +255,26 @@ html = template(items=itertools.islice(events_by_day.items(), 3, 4))
HTML(html)
```
#### When rendered, it will look something like this:
#### 渲染后,它将看起来像这样:
#### 2020-08-25
* **&lt;REDACTED&gt;** \-- 2020-08-25 08:30:00 (0:45:00)
* **&lt;REDACTED&gt;** \-- 2020-08-25 10:00:00 (1:00:00)
* **&lt;REDACTED&gt;** \-- 2020-08-25 11:30:00 (0:30:00)
* **&lt;REDACTED&gt;** \-- 2020-08-25 13:00:00 (0:25:00)
* **&lt;编辑&gt;** \-- 2020-08-25 08:30:00 (0:45:00)
* **&lt;编辑&gt;** \-- 2020-08-25 10:00:00 (1:00:00)
* **&lt;编辑&gt;** \-- 2020-08-25 11:30:00 (0:30:00)
* **&lt;编辑&gt;** \-- 2020-08-25 13:00:00 (0:25:00)
* **Busy** \-- 2020-08-25 15:00:00 (1:00:00)
* **&lt;REDACTED&gt;** \-- 2020-08-25 15:00:00 (1:00:00)
* **&lt;REDACTED&gt;** \-- 2020-08-25 19:00:00 (1:00:00)
* **&lt;REDACTED&gt;** \-- 2020-08-25 19:00:12 (1:00:00)
* **&lt;编辑&gt;** \-- 2020-08-25 15:00:00 (1:00:00)
* **&lt;编辑&gt;** \-- 2020-08-25 19:00:00 (1:00:00)
* **&lt;编辑&gt;** \-- 2020-08-25 19:00:12 (1:00:00)
### Endless options with Python and Jupyter
### Python 和 Jupyter 的无穷选择
This only scratches the surface of what you can do by parsing, analyzing, and reporting on the data that various web services have on you.
通过解析,分析和报告各种 Web 服务所拥有的数据,这只是您可以做的事情的表面。
Why not try it with your favorite service?
为什么不尝试使用您最喜欢的服务呢?
--------------------------------------------------------------------------------
@ -306,7 +282,7 @@ via: https://opensource.com/article/20/9/calendar-jupyter
作者:[Moshe Zadka][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
译者:[stevenzdg988](https://github.com/stevenzdg988)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出