create-smart-link-app
Advanced tools
Comparing version
@@ -26,3 +26,3 @@ /*eslint-disable*/ | ||
.option('--info', 'print environment debug info') | ||
//.option('--git', 'whether initialize git and commit for the created project,default true') | ||
.option('--git', 'whether initialize git and commit for the created project,default true') | ||
.option('--template <path-to-template>', 'specify a template for the created project') | ||
@@ -71,6 +71,6 @@ .allowUnknownOption() | ||
createApp(projectName, program.verbose, program.template); | ||
createApp(projectName, program.verbose, program.template,program.git); | ||
}; | ||
function createApp(name, verbose, template) { | ||
function createApp(name, verbose, template,initGit) { | ||
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=10'); | ||
@@ -109,3 +109,3 @@ if (unsupportedNodeVersion) { | ||
installTemplate(root, appName, verbose, originalDirectory, template) | ||
installTemplate(root, appName, verbose, originalDirectory, template,initGit) | ||
.then(copyTemplate) | ||
@@ -120,3 +120,3 @@ .then(installTemplateDependencies) | ||
function installTemplate(root, appName, verbose, originalDirectory, template) { | ||
function installTemplate(root, appName, verbose, originalDirectory, template,initGit) { | ||
return new Promise((resolve, reject) => { | ||
@@ -150,3 +150,3 @@ let templateToInstall = template || '@smart-link/template-shared'; | ||
} | ||
resolve({ appPath: root, templateToInstall, isWorkspaces }); | ||
resolve({ appPath: root, templateToInstall, isWorkspaces,initGit }); | ||
}); | ||
@@ -156,3 +156,3 @@ }); | ||
function copyTemplate({ appPath, templateToInstall, isWorkspaces }) { | ||
function copyTemplate({ appPath, templateToInstall, isWorkspaces,initGit }) { | ||
return new Promise((resolve, reject) => { | ||
@@ -201,7 +201,7 @@ const packageMatch = templateToInstall.match(/^(@[^/]+\/)?([^@]+)?(@.+)?$/); | ||
} | ||
resolve({ appPath, templateScope, templateName, templatePackage, isWorkspaces }); | ||
resolve({ appPath, templateScope, templateName, templatePackage, isWorkspaces,initGit }); | ||
}); | ||
} | ||
function installTemplateDependencies({ appPath, templateScope, templateName, templatePackage, isWorkspaces }) { | ||
function installTemplateDependencies({ appPath, templateScope, templateName, templatePackage, isWorkspaces,initGit }) { | ||
return new Promise((resolve, reject) => { | ||
@@ -234,7 +234,7 @@ const command = 'yarnpkg'; | ||
} | ||
resolve({ appPath, templateScope, templateName, isWorkspaces }); | ||
resolve({ appPath, templateScope, templateName, isWorkspaces,initGit }); | ||
}); | ||
} | ||
function cleanTemplate({ appPath, templateScope, templateName, isWorkspaces }) { | ||
function cleanTemplate({ appPath, templateScope, templateName, isWorkspaces,initGit }) { | ||
return new Promise((resolve, reject) => { | ||
@@ -267,14 +267,21 @@ const command = 'yarnpkg'; | ||
resolve({ appPath }); | ||
resolve({ appPath,initGit }); | ||
}); | ||
} | ||
function handleGit({ appPath }) { | ||
function handleGit({ appPath ,initGit}) { | ||
return new Promise((resolve, reject) => { | ||
if(!initGit){ | ||
resolve(); | ||
return; | ||
} | ||
const gitignoreExists = fs.existsSync(path.join(appPath, 'gitignore')); | ||
if (gitignoreExists) { | ||
fs.moveSync(path.join(appPath, 'gitignore'), path.join(appPath, '.gitignore'), []); | ||
if (!gitignoreExists) { | ||
resolve(); | ||
return; | ||
} | ||
fs.moveSync(path.join(appPath, 'gitignore'), path.join(appPath, '.gitignore'), []); | ||
!isInGitRepository() && tryGitInit(appPath) && tryGitCommit(appPath); | ||
@@ -281,0 +288,0 @@ resolve(); |
{ | ||
"name": "create-smart-link-app", | ||
"coment": "@smart-link/create-app", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "keywords": [ |
16848
1.29%370
1.65%