-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] add a possibility to generate subtheme for t3kit project
- Loading branch information
Showing
10 changed files
with
379 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,89 @@ | ||
// 'use strict' | ||
'use strict' | ||
|
||
const _ = require('lodash') | ||
// const variables = require('../variables') | ||
// const helpers = require('../helpers') | ||
const helpers = require('../helpers') | ||
const exec = require('child_process').exec | ||
|
||
// const git = module.exports = {} | ||
const git = module.exports = {} | ||
|
||
// clone mobileApp_template | ||
git.clone = function clone (cache, link) { | ||
let cmd = { | ||
spinner: `Cloning subtheme ${cache.whatToDo}`, | ||
str: `git clone --single-branch -b master ${link} ${cache.dirName}`, | ||
spinerSucceed: `${cache.whatToDo} template successfully cloned` | ||
} | ||
return helpers.execCMD(cmd, cache) | ||
} | ||
|
||
// remove previous git repo | ||
git.removeRepo = function removeRepo (cache) { | ||
let cmd = { | ||
// spinner: '', | ||
str: `rm -rf .git` | ||
// spinerSucceed: '' | ||
} | ||
return helpers.execCMD(cmd, cache) | ||
} | ||
|
||
// git add | ||
git.init = function init (cache) { | ||
let cmd = { | ||
// spinner: '', | ||
str: `git init` | ||
// spinerSucceed: '' | ||
} | ||
return helpers.execCMD(cmd, cache) | ||
} | ||
|
||
// git add | ||
git.add = function add (cache) { | ||
let cmd = { | ||
// spinner: '', | ||
str: `git add .` | ||
// spinerSucceed: '' | ||
} | ||
return helpers.execCMD(cmd, cache) | ||
} | ||
|
||
// git commit | ||
git.commit = function commit (cache, commitMessage) { | ||
let cmd = { | ||
// spinner: '', | ||
str: `git commit -m "${commitMessage}"` | ||
// spinerSucceed: '' | ||
} | ||
return helpers.execCMD(cmd, cache) | ||
} | ||
|
||
// git checkout | ||
git.checkout = function checkout (cache) { | ||
let cmd = { | ||
str: `git checkout ${cache.templateVersion}` | ||
} | ||
return helpers.execCMD(cmd, cache) | ||
} | ||
|
||
|
||
git.getLastTag = function getLastTag (cache) { | ||
return new Promise(function (resolve, reject) { | ||
let str = 'git describe --abbrev=0 --tags' | ||
let lastTag = {} | ||
exec(str, { maxBuffer: 2000 * 1024 }, (error, stdout) => { | ||
if (error) { | ||
reject(new Error(error)) | ||
} else { | ||
if (_.isEmpty(stdout)) { | ||
lastTag = { lastTag: false } | ||
} else { | ||
var match = stdout.match(/\n/i) | ||
lastTag = stdout.slice(0, match.index) | ||
lastTag = { lastTag: lastTag } | ||
} | ||
helpers.addTo(cache, lastTag) | ||
resolve(cache) | ||
} | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
// 'use strict' | ||
'use strict' | ||
|
||
// const shell = require('shelljs') | ||
// const helpers = require('../helpers') | ||
const shell = require('shelljs') | ||
const helpers = require('../helpers') | ||
// const variables = require('../variables') | ||
// var fs = require('fs') | ||
|
||
// const parse = module.exports = {} | ||
const parse = module.exports = {} | ||
|
||
// replace string in files | ||
parse.replaceString = function replaceString (cache, oldString, newString) { | ||
return new Promise(function (resolve) { | ||
shell.sed('-i', helpers.escapeRegExp(oldString), newString, cache.files) | ||
// shell.sed('-i', oldString, newString, cache.files) | ||
resolve(cache) | ||
}) | ||
} | ||
|
||
parse.replaceStringInFile = function replaceStringInFile (cache, oldString, newString, file) { | ||
return new Promise(function (resolve) { | ||
shell.sed('-i', helpers.escapeRegExp(oldString), newString, file) | ||
resolve(cache) | ||
}) | ||
} |
Oops, something went wrong.