Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
light-generator
Advanced tools
一个非常轻量的脚手架生成器,用于各种脚手架的生成。
核心功能:
import {LightGenerator} from 'light-generator';
const generator = new LightGenerator().defineNpmPackage({
npmPackage: 'egg-boilerplate-simple',
targetPath
});
await generator.run({
name: 'demo'
});
默认会将模板中的下划线前缀的文件替换为正常文件名,并替换模板中的 {{xxx}}
变量为传入的参数。
LightGenerator
通过定义一系列格式,返回一个特定格式的生成器,执行该生成器即可拿到相应的结果。
interface LightGenerator {
defineLocalPath(options): CommonGenerator;
defineNpmPackage(options): CommonGenerator;
}
interface CommonGenerator {
async getParameterList(): object;
async run(replaceParameter?: object);
}
生成本地路径的模板
示例
const localGenerator = new LightGenerator().defineLocalPath({
templatePath: join(__dirname, './fixtures/boilerplate-2'),
targetPath
});
生成一个 npm 包资源类型的模板
示例
const npmGenerator = new LightGenerator().defineNpmPackage({
npmPackage: 'egg-boilerplate-simple',
targetPath
});
生成器可以在生成完模板文件后,做一些自定义的操作,比如替换内容,修改文件名等。
简单的来说,规则是一个函数,参数为当前文件路径,用于对当前文件进行操作。
示例
import {LightGenerator} from 'light-generator';
const customRule = async (currentFilePath) => {
// TODO
}
const generator = new LightGenerator({
copyRule: [customRule]
});
内置了一些默认规则,比如
这些规则默认已经内置,并且生效。
示例
import {LightGenerator, ignoreRule} from 'light-generator';
const generator = new LightGenerator({
copyRule: [ignoreRule]
});
如果不希望这些规则生效,请在初始化时关闭,并自行传递规则。
示例
import {LightGenerator, ignoreRule} from 'light-generator';
const generator = new LightGenerator({
disableDefaultRule: true,
copyRule: [ignoreRule]
});
默认情况下,会拷贝整个模板目录的内容到目标目录,但是在 package.json
中加入 boilerplateConfig
段落可以额外配置这个行为。
{
"boilerplateConfig": {
"root": "template",
"replaceParameter": "index.js",
"replaceFile": [
"src/index.ts"
]
}
}
参数
boilerplateConfig
字段,默认为 boilerplate
目录index.js
README.md
,相对于 root此模块部分核心代码从 serverless 模块中抽取。
FAQs
light generator for generate a boilerplate
The npm package light-generator receives a total of 21 weekly downloads. As such, light-generator popularity was classified as not popular.
We found that light-generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.