|
|
@ -11,7 +11,7 @@ def run(steps) |
|
|
|
C "[ {result.status ? "OK" : "FAILED"} ] {result.message}" |
|
|
|
|
|
|
|
def addProRouterViewsPlugin() |
|
|
|
const configFile = file "./vite.config.js" |
|
|
|
const configFile = file "vite.config.js" |
|
|
|
const configContent = try nfs.readFileSync(configFile, 'utf-8') |
|
|
|
return { |
|
|
|
desc: "Adding proRouterViews() plugin to vite.config.js", |
|
|
@ -28,26 +28,26 @@ def addProRouterViewsPlugin() |
|
|
|
} |
|
|
|
|
|
|
|
def generateRouterFile() |
|
|
|
const routerFile = file './src/router.imba' |
|
|
|
const routerContent = try nfs.readFileSync(routerFile, 'utf-8') |
|
|
|
const destinationFile = file 'src/router.imba' |
|
|
|
const destinationContent = try nfs.readFileSync(destinationFile, 'utf-8') |
|
|
|
return { |
|
|
|
desc: "Generating src/router.imba file" |
|
|
|
run: do |
|
|
|
if routerContent |
|
|
|
if /R\.init/.test(routerContent) |
|
|
|
if destinationContent |
|
|
|
if /R\.init/.test(destinationContent) |
|
|
|
return status: true, message: "router seems to be ALREADY on place" |
|
|
|
else |
|
|
|
return status: false, message: "file already exist" |
|
|
|
else |
|
|
|
try |
|
|
|
nfs.cp source: './node_modules/pro-router-imba2/src/router.imba', destination: './src/' |
|
|
|
const routerContent = nfs.readFileSync(file('node_modules/pro-router-imba2/src/router.imba'), 'utf-8') |
|
|
|
nfs.writeFileSync(destinationFile, routerContent.replace("./", 'pro-router-imba2')) |
|
|
|
nfs.cp source: 'node_modules/pro-router-imba2/src/router.imba', destination: './src/' |
|
|
|
return status: true, message: "generated successfuly" |
|
|
|
catch |
|
|
|
return status: false, message: 'unable to copy router.imba template' |
|
|
|
} |
|
|
|
|
|
|
|
C nfs |
|
|
|
|
|
|
|
if process.argv.slice(2) == "init" |
|
|
|
run([addProRouterViewsPlugin(), generateRouterFile()]) |
|
|
|
else |
|
|
|