问题标签 [package-development]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - 我的 NPM CLI 包可以在 CMD 上执行而无需全局安装吗?
我写了一个 NPM 包,它有自己的 CLI 命令。
让我们将该包命名为xyz
并想象它现在可以在npmjs.com上使用
所以,假设用户通过运行在他的项目中安装这个包npm install xyz
。
现在他想xyz
在他的项目中的终端上运行 package 提供的 CLI 命令。
xyz do_this
这可以在不由用户全局安装此软件包的情况下完成吗?或者没有任何进一步的用户配置?
这是package.json
xyz 包的一部分。
r - 如何为具有并行后端的函数编写 R 包文档
我想把这个函数写成一个R
包
编辑
.
我需要的
假设我的向量x
是如此之大,以至于它将需要一个串行处理5 hours
来完成任务x <- 1:9e9
,例如并行处理可以提供帮助的地方。我如何包括:
在我的.R
文件和DESCRIPTION
文件中,以便它值得R
包装文档?
r - 当我有多个函数来执行复合任务时,如何编写 R 包文档?
我有以下 R 函数,我想用它们来获得任何数字向量的总和、平方和和立方和:
更正的功能
我想产生向量的总和,向量的平方和以及同一向量的立方和。我希望它在我只运行一个函数后打印三个结果,并将包含在 R 包文档中。
我知道如何通过记录 R 文件夹及其文件以及DESCRIPTION 文件来编写仅具有一项功能的R 程序包,而其余的roxygen2
则为devtools
我完成。
我想
如果 x <- c(1, 2) 我想要这种格式。
ssssssssssssssssssssssssssssssssssss
3 5 9
仅包含软件包中的一个功能。
请说明您在输出中使用的向量。
php - 在我的 laravel 包测试中找不到视图
我正在尝试为我的Laravel 包添加刀片指令。
一切都很好,但在测试阶段,我收到了这个错误:
我应该输入$this->loadViewsFrom(...)
服务提供商吗?
查看路径:/tests/resources/views/userWalletBalance.blade.php
测试路径:/tests/Feature/BladeTest.php
我还尝试将resources
目录移动到Feature
目录中(在 旁边BladeTest.php
),但遇到了同样的错误。
这是我的代码BladeTest.php
:
r - Building my unaltered package suddenly fails: for Vignettes and 'arch = x64'
Context
I've been developing a proprietary package (call it "my_pkg
") with vignettes, in RStudio with the latest version (4.1.1) of R. I'm working on a Lenovo ThinkPad with the following software
as provided by Sys.info()
.
Until recently, my devtools
workflow has been reasonably smooth (with one occasional exception). However, I've begun to encounter a very puzzling error, which occurs under conditions virtually identical to those beforehand, when the workflow proceeded without issue.
Despite the fact that my vignettes always built successfully before, and I have not edited them in the meantime, the build now fails for architecturally specific reasons...
...when and only when I include the vignettes in the build.
I have reinstalled R (and Rtools and RStudio) from scratch, reinstalled devtools
(and its dependencies), and "rewound" my project to the last Git commit at which devtools::check()
succeeded. I have also walked through extensive troubleshooting with responders like @SteffenMoritz and @Alexis, for whom I have appended further information in the section Info by Request.
Unfortunately, nothing has worked.
Failure With devtools::check()
When I run devtools::check()
, everything starts promisingly...
...until the step testing if installed package can be loaded from temporary location
. Here an error occurs:
The .Last.error.trace
suggests an issue with pkgbuild
specifically:
I have no clue as to why the architecture
should be an issue only now. There have been no substantive changes to my computer.
Despite the message package installation failed
, and despite the fact that I've run devtools::
check()
rather than devtools::
install()
, the package acts as if it were "halfway" installed! I can type my_p
in the console, and RStudio will autocomplete my_pkg
; and I can then type my_pkg::
and RStudio will supply the standard autocompletion list of the functions in my_pkg
, which are all available.
However, typing my_pkg::
not only summons the @export
ed functions but also exposes my internal functions and data, as if I had typed my_pkg
:::
!
Success With devtools::install()
or devtools::build(vignettes = FALSE)
Oddly, when I actually run devtools::install()
, or comparably devtools::build_vignettes(vignettes = FALSE)
, the process completes without a hitch!
Now, the autocompletion works entirely as expected, and only the appropriate functions are exposed by my_pkg::
and my_pkg:::
respectively.
Failure With devtools::install(build_vignettes = TRUE)
or devtools::build()
Yet there is one further plot twist. When I use devtools::install(
build_vignettes = TRUE
)
, or comparably devtools::build()
, I get a similar error to that with devtools::check()
:
Success With devtools::build_vignettes()
Bizarrely, despite the issues above with building vignettes, everything somehow runs smoothly when I call devtools::build_vignettes()
sans arguments or with dependencies = TRUE
:
Note
Assuming that the fault was mine, and that I had unwittingly introduced an issue somewhere within my R project, I switched to an entirely different Git branch. The most recent commit to this branch had passed devtools::check()
with flying colors. However, even after switching over to this "safe" branch, those same issues continued!
Between that last successful check and when the issues began, I made no updates to:
- R itself
- RStudio
- Any R packages
- My computer's software (with the exception of a minor anti-malware update from Microsoft).
- My computer's hardware
Likewise, the vignettes have been present since far earlier in the project.
Conclusion
I'm hoping to roll out a proof of concept for my_pkg
in the rather near future, and the vignettes are quite essential to its usability.
Info by Request
Since "my_pkg
" is proprietary, I here anonymize my personal and organizational information (names, filepaths, etc.) as above.
For @SteffenMoritz
Would you mind sharing your DESCRIPTION file and the vignette header/meta information?
The DESCRIPTION
file:
The vignette headers:
intro.Rmd
:
backstory.Rmd
:
library.Rmd
template.Rmd
usage.Rmd
For @Alexis
What do you see if you open the
.Rproj
file with a text editor?
The my_pkg.Rproj
file, as opened in MS Notepad. NOTE: This file has not been modified since the very initial commit.
By request
Does it work if you run
R CMD build/INSTALL ...
from the command line?
I also built from the command line
but I got the same output echoed above:
r - 将错误消息与包中的错误条件分开
背景
包可以包含很多功能。其中一些需要提供信息丰富的错误消息,并且可能需要函数中的一些注释来解释发生了什么/为什么发生。f1
假设f1.R
文件中的示例。所有文档和评论(错误的原因和条件的原因)都集中在一个地方。
例如,我创建一个单独的conds.R
,指定一个函数(和w
警告、s
建议)等。
然后在f.R
脚本中,我可以定义f2
为
确实会引发错误,并且在它之上有一个很好的回溯并在控制台中使用调试选项重新运行。此外,作为包维护者,我更喜欢这样做,因为它避免考虑编写简洁的 if 语句 + 1 行错误消息或在tryCatch
语句中对齐注释。
问题
是否有理由(不是对语法的看法)避免conds.R
在包中编写 a ?
php - Laravel 8 包开发 pushMiddlewareToGroup
将 Laravel 版本从 6.0 更新到 8.0 后,推送使用的中间件$router->pushMiddlewareToGroup
无法正常工作。
r - 如何将单位放入 roxygen
我正在使用 roxygen2 记录数据集(用于我的包开发)。我试图将立方米(m^2)作为我的一个变量的单位,但当我试图查看文档时它保持不变(m^2)?数据。如何在 roxygen2 中生成单位?
谢谢
laravel - 如何在自定义 laravel 包中访问 Sanctum 包
我想访问在项目路由中运行良好的 laravel sanctum auth 我正在制作一个自定义的 api 包,它需要在自定义包路由中使用相同的 sanctum 身份验证