Skip to content

Commit

Permalink
For #4 scaffold cms utility to upsert a single content item, all cont…
Browse files Browse the repository at this point in the history
…ent items of a single content type or all content items of all content types, using a fuzzy search command line widget
  • Loading branch information
victorkane committed Nov 17, 2018
1 parent 05f5cea commit 9db84ca
Show file tree
Hide file tree
Showing 3 changed files with 438 additions and 0 deletions.
40 changes: 40 additions & 0 deletions cms/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict'
var inquirer = require('inquirer')
var shell = require('shelljs')
var fs = require('fs')
var path = require('path')

inquirer.registerPrompt('fuzzypath', require('inquirer-fuzzy-path'))

var questions = [
{
type: 'fuzzypath',
name: 'file',
rootPath: '/home/durabledrupal/ddcmr/dev/cms/content',
message: 'Choose single file, entire content type (folder) or all content (parent content folder) to upsert'
}
]

inquirer.prompt(questions).then(answers => {
console.log(JSON.stringify(answers, null, ' '));
var dirname = path.basename(path.dirname(answers.file))
var basename = path.basename(answers.file)
var extname = path.extname(answers.file)
console.log('basename', basename)
console.log('extname', extname)
fs.stat(answers.file, function(err, stats) {
if (stats.isDirectory()) {
console.log('directory')
if (basename === 'content') {
console.log('upsert all')
} else {
console.log('upsert all', basename)
}
}
if (stats.isFile()) {
console.log('file')
console.log('upsert content item ', basename, ' for content type ', dirname)
}
console.log('stats', stats)
})
})
Loading

0 comments on commit 9db84ca

Please sign in to comment.