angular-schematics - Angular Schematics:创建自定义树文件夹和文件
问题描述
我刚刚开始学习 Schematics,我的第一个任务是使用我的Angular应用程序中的自定义示意图生成自定义的文件夹树和空文件
例如 :
我想生成这棵树:
folderOne
|__ fileOne.ts
folderTwo
|__ fileTwo.ts
folderThree
|__ subfolderA
|__ fileThree.ts
当然应该取决于运行原理图命令的源位置
(相对路径)
有什么快速(模板)的方法吗?
建议??
解决方案
在您的文件模板中
__fistVariable@dasherize__
|__firstVariable@dasherize__.ts
__secondVariable@dasherize__
|__secondVariable@dasherize__.ts
你的原理图功能:
const templateSource = apply(url("./files"), [
template({
..._options,
...strings
})
]);
return mergeWith(templateSource)(tree,_context);
在你的 schema.json
"properties": {
"one": {
"type": "string",
"description": "Variable 1",
"$default": {
"$source": "argv",
"index": 0
},
"minLength": 1,
"x-prompt": "Enter the entity name (camelCase || dasherized)"
},
"two":{
"type": "string",
"description": "Variable two",
"$default": {
"$source": "argv",
"index": 1
},
"minLength": 1,
"x-prompt": "Enter the entity name (camelCase || dasherized)"
}
},
"required": ["one", "two"]
推荐阅读
- flutter - Flutter 布局 -3 列
- python - 为什么 gspread 中的 worksheet.get() 不起作用?
- sql - PL/SQL 如何获取我正在查询的表的计数?如何在 COUNT 中使用 NEW?
- flutter - 无法在颤动中将消息从 SendPort 发送到 ReceivePort
- r - 如何在数据集列表上运行 lm 模型?
- python - 为两个数组 x 和 y 获得完全相同的乘积的 Pythonic 方法是什么,其中 y 被任意改组?
- flutter - Flutter:将数据发送回特定列表项
- c# - c# 根据属性从类列表中选择实例
- java - java中的蛇游戏不会检测箭头键(蛇不会响应输入)
- vue.js - Can't beforeCreate 工作与 Nuxt.js 中的 asyncData 相同