Skip to content

Commit

Permalink
refactoring: duplicate and create
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Oct 5, 2016
1 parent d8c47fa commit 02e9e00
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 14 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
cleanSlug,
config,
save,
abeCreate
cmsOperations
} from '../../'

var duplicate = function(oldFilePath, template, newPath, name, req, isUpdate = false) {
Expand Down Expand Up @@ -46,7 +46,7 @@ var duplicate = function(oldFilePath, template, newPath, name, req, isUpdate = f
}
Hooks.instance.trigger('afterDuplicate', json, oldFilePath, template, newPath, name, req, isUpdate)

var pCreate = abeCreate(template, newPath, name, req, json, (isUpdate) ? false : true)
var pCreate = cmsOperations.create(template, newPath, name, req, json, (isUpdate) ? false : true)
pCreate.then((resSave) => {
resolve(resSave)
},
Expand Down
7 changes: 7 additions & 0 deletions src/cli/cms/operations/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import create from './create'
import duplicate from './duplicate'

export {
create
,duplicate
}
6 changes: 2 additions & 4 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ import Create from './cms/Create'

import config from './core/config/config'

import abeCreate from './cms/operations/abe-create'
import abeDuplicate from './cms/operations/abe-duplicate'
import {save, checkRequired, saveJson} from './cms/operations/save'

import abeProcess from './extend/abe-process'
import Hooks from './extend/abe-hooks'
import Plugins from './extend/abe-plugins'

import * as cmsData from './cms/data'
import * as cmsOperations from './cms/operations'
import * as cmsTemplate from './cms/templates'
import * as coreUtils from './core/utils'

export {
cmsData
,cmsOperations
,cmsTemplate
,coreUtils

Expand All @@ -70,8 +70,6 @@ export {
,Handlebars
,clc
,Util
,abeCreate
,abeDuplicate
,slugify
,cleanSlug
,FileParser
Expand Down
4 changes: 2 additions & 2 deletions src/server/routes/get-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import {
cleanSlug,
config,
save,
abeCreate,
cmsOperations,
Hooks
} from '../../cli'

var route = function(req, res, next) {
Hooks.instance.trigger('beforeRoute', req, res, next)

var p = abeCreate(req.query.selectTemplate, req.query.filePath, req.query.tplName, req)
var p = cmsOperations.create(req.query.selectTemplate, req.query.filePath, req.query.tplName, req)

p.then((resSave) => {
var result = {
Expand Down
4 changes: 2 additions & 2 deletions src/server/routes/get-duplicate.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
abeDuplicate,
cmsOperations,
Hooks
} from '../../cli'

var route = function(req, res, next) {
Hooks.instance.trigger('beforeRoute', req, res, next)

var p = abeDuplicate(req.query.oldFilePath, req.query.selectTemplate, req.query.filePath, req.query.tplName, req)
var p = cmsOperations.duplicate(req.query.oldFilePath, req.query.selectTemplate, req.query.filePath, req.query.tplName, req)

p.then((resSave) => {
var result = {
Expand Down
1 change: 0 additions & 1 deletion src/server/routes/get-list-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
cleanSlug,
config,
save,
abeCreate,
Hooks,
Plugins
} from '../../cli'
Expand Down
1 change: 0 additions & 1 deletion src/server/routes/get-list-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
cleanSlug,
config,
save,
abeCreate,
Hooks
} from '../../cli'

Expand Down
4 changes: 2 additions & 2 deletions src/server/routes/get-update.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
abeDuplicate,
cmsOperations,
Hooks
} from '../../cli'

var route = function(req, res, next) {
Hooks.instance.trigger('beforeRoute', req, res, next)

var p = abeDuplicate(req.query.oldFilePath, req.query.selectTemplate, req.query.filePath, req.query.tplName, req, true)
var p = cmsOperations.duplicate(req.query.oldFilePath, req.query.selectTemplate, req.query.filePath, req.query.tplName, req, true)

p.then((resSave) => {
var result = {
Expand Down

0 comments on commit 02e9e00

Please sign in to comment.