build: update component init

This commit is contained in:
xuxiaoyan 2019-01-23 14:11:37 +08:00
parent 6f354f109f
commit cd75c09b6a
2 changed files with 8 additions and 5 deletions

View File

@ -13,7 +13,7 @@ const CWD = process.cwd()
const COMPONENTS_PATH = path.resolve(CWD, './components')
const EXPECT_SHELL = path.resolve(CWD, './build/template.exp')
const DEMO_INDEX_PATH = path.resolve(CWD, './examples/demo-index.js')
const DEMO_INDEX_PATH_INDEMAND = path.resolve(CWD, './examples/demo-index.indemand.js')
const TYPES = path.resolve(CWD, './types/index.d.ts')
const COMPONENT_INDEX = path.resolve(CWD, './components/index.js')
const COMPONENT_JSON = path.resolve(CWD, './examples/components.json')
@ -47,7 +47,7 @@ function changeKebabToCamel(str) {
}
function sync(answers) {
return Promise.all([syncToComponentJson(answers), syncToExample(answers), syncToIndex(answers), syncToExampleIndemand(answers)]).then(() =>answers)
return Promise.all([syncToComponentJson(answers), syncToExample(answers), syncToIndex(answers), syncToTypes(answers)]).then(() =>answers)
}
function syncToExample(answers) {
@ -58,12 +58,12 @@ function syncToExample(answers) {
.then(str => fs.writeFileAsync(DEMO_INDEX_PATH, str, 'utf8'))
.then(() => answers)
}
function syncToExampleIndemand(answers) {
fs.readFileAsync(DEMO_INDEX_PATH_INDEMAND, 'utf8')
function syncToTypes(answers) {
fs.readFileAsync(TYPES, 'utf8')
.then(str => {
return compile(answers, str)
})
.then(str => fs.writeFileAsync(DEMO_INDEX_PATH_INDEMAND, str, 'utf8'))
.then(str => fs.writeFileAsync(TYPES, str, 'utf8'))
.then(() => answers)
}

3
types/index.d.ts vendored
View File

@ -40,6 +40,7 @@ export class Progress extends MandComponent { }
export class Radio extends MandComponent { }
export class RadioList extends MandComponent { }
export class ResultPage extends MandComponent { }
export class Ruler extends MandComponent { }
export class ScrollView extends MandComponent { }
export class ScrollViewMore extends MandComponent { }
export class ScrollViewRefresh extends MandComponent { }
@ -58,6 +59,8 @@ export class Tag extends MandComponent { }
export class Tip extends MandComponent { }
export class Transition extends MandComponent { }
export class WaterMark extends MandComponent { }
/* @init<%export class ${componentNameUpper} extends MandComponent { }%> */
// declare module 'mand-mobile/lib/image-reader/image-processor' {