Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
fix: make script
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionad-Morotar committed Jun 4, 2021
1 parent 3d2a7ec commit 18b75db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ default: help

help:
@echo " Documents & Usage"
@echo " make new <module-title> <module-cn-title> --- create a new module,eg. 'make new button button-cn-name'"
@echo " make module <module-title> <module-cn-title> --- create a new module,eg. 'make new button button-cn-name'"
@echo " make modules-entry --- regenerate components.js in wox-mouldes"

new-module:
# 创建新模块(创建后之后,需要补全以下模块的 meta.json)
module:
node build/module/new-module.js $(filter-out $@,$(MAKECMDGOALS))
# gulp watch

# 重新生成模块入口文件(通常在补全 meta.json 后调用)
modules-entry:
node build/module/modules-entry.js
6 changes: 3 additions & 3 deletions build/module/modules-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const endOfLine = require('os').EOL

// FIXME 从 constant 引入常量 ModuleTypeEnums.BASE
const baseType = '基础模块'
const components = require('../../packages/modules/components.json')
const components = require('../../packages/wox-modules/components.json')
const names = Object.keys(components)
const requires = []
const metas = names.map(name => {
const upperName = uppercamelcase(name)
const metaFile = path.join(__dirname, '../../packages/modules', components[name], './meta.json')
const metaFile = path.join(__dirname, '../../packages/wox-modules', components[name], './meta.json')
const meta = JSON.parse(fs.readFileSync(metaFile, 'utf-8'))

requires.push(`import ${upperName} from '${components[name]}'`)
Expand Down Expand Up @@ -56,6 +56,6 @@ const template = render(TEMPLATE, {
.replace(/\r\n|\n|\r/g, endOfLine + ' ')
}).replace(/"component":\s"([^"]*)"/g, '"component": $1')

const SAVE_PATH = path.join(__dirname, '../../packages/modules/components.js')
const SAVE_PATH = path.join(__dirname, '../../packages/wox-modules/components.js')
fs.writeFileSync(SAVE_PATH, template)
console.log('[build entry] DONE:', SAVE_PATH)
6 changes: 3 additions & 3 deletions build/module/new-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const fileSave = require('file-save')
// TODO 校验 name,kabe-case
const title = process.argv[2]
const description = process.argv[3] || title
const moduleSavePath = path.resolve(__dirname, '../../packages/modules', title)
const moduleSavePath = path.resolve(__dirname, '../../packages/wox-modules', title)

/* 生成 components.json */
const componentJSONFile = '../../packages/modules/components.json'
const componentJSONFile = '../../packages/wox-modules/components.json'
const componentsFile = require(componentJSONFile)
if (componentsFile[title]) {
console.error(`模块 ${title} 已存在,请重新命名。`)
Expand Down Expand Up @@ -68,7 +68,7 @@ export default {
{
filename: 'meta.json',
content: `{
"title": "${title}",
"title": "${description}",
"description": "${description}",
"cover": "",
"is-base-category": false,
Expand Down

0 comments on commit 18b75db

Please sign in to comment.