|
|
@ -47,6 +47,19 @@ def generateRouterFile() |
|
|
|
catch |
|
|
|
return status: false, message: 'unable to copy router.imba template' |
|
|
|
} |
|
|
|
def initializeViewsFile() |
|
|
|
const path = 'src/views.json' |
|
|
|
const viewsFile = file path |
|
|
|
|
|
|
|
return { |
|
|
|
desc: "Initializing views list file - src/views.json" |
|
|
|
run: do |
|
|
|
if nfs.existsSync(path) |
|
|
|
return status: true, message: ["file already exists"] |
|
|
|
else |
|
|
|
nfs.writeFileSync viewsFile, "[]" |
|
|
|
return status: true, message: ["initialized successfuly"] |
|
|
|
} |
|
|
|
|
|
|
|
def importRouter |
|
|
|
const indexFile = file 'src/index.js' |
|
|
@ -60,7 +73,7 @@ def importRouter |
|
|
|
return status: true, message: "import definition already there" |
|
|
|
else |
|
|
|
try |
|
|
|
nfs.writeFileSync indexFile, "import './router.imba'\n" + indexContent + "\nR.url_changed() // the best if you move it right before imba.mount" |
|
|
|
nfs.writeFileSync indexFile, "import './router.imba'\n" + indexContent |
|
|
|
return status: true, message: "definition added successfuly" |
|
|
|
catch |
|
|
|
return status: false, message: "failed during writing to file" |
|
|
@ -69,6 +82,6 @@ def importRouter |
|
|
|
} |
|
|
|
|
|
|
|
if process.argv.slice(2) == "init" |
|
|
|
run([addProRouterViewsPlugin(), generateRouterFile(), importRouter()]) |
|
|
|
run([addProRouterViewsPlugin(), generateRouterFile(), initializeViewsFile(), importRouter()]) |
|
|
|
else |
|
|
|
C("For initial configuration of pro router use command: pro-router init") |