@blucass/create-project
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -52,5 +52,5 @@ "use strict"; | ||
name: 'projectName', | ||
message: '项目名称', | ||
message: '项目名称' | ||
}, { | ||
onCancel: () => true, | ||
onCancel: () => true | ||
}); | ||
@@ -71,7 +71,7 @@ if (projectName.trim() === '') { | ||
{ | ||
title: 'React Lite', | ||
value: 'react-lite', | ||
description: '基于 create-react-app,支持自定义配置', | ||
}, | ||
], | ||
title: 'React Lite for PC', | ||
value: 'react-lite-pc', | ||
description: '基于 create-react-app,支持自定义配置' | ||
} | ||
] | ||
}); | ||
@@ -78,0 +78,0 @@ return projectType; |
export declare const Boilerplate_Repos: { | ||
'react-lite': string; | ||
'react-lite-pc': { | ||
url: string; | ||
branch: string; | ||
}; | ||
}; |
@@ -5,3 +5,6 @@ "use strict"; | ||
exports.Boilerplate_Repos = { | ||
'react-lite': '', | ||
'react-lite-pc': { | ||
url: 'git@github.com:wqcstrong/boilerplate.git', | ||
branch: 'react-lite-pc' | ||
} | ||
}; |
export declare const checkCommandInstall: (command: string) => boolean; | ||
export declare const checkYarnInstall: () => boolean; | ||
export declare const downloadRepos: (repos: string, targetPath: string, projectName: string) => void; | ||
export declare const downloadRepos: (repoObj: I.Repo, localPath: string, projectName: string) => void; |
@@ -8,5 +8,7 @@ "use strict"; | ||
const child_process_1 = require("child_process"); | ||
const git_clone_1 = __importDefault(require("git-clone")); | ||
const fs_1 = __importDefault(require("fs")); | ||
const ora_1 = __importDefault(require("ora")); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const git_clone_1 = __importDefault(require("./git-clone")); | ||
const path_1 = __importDefault(require("path")); | ||
const checkCommandInstall = (command) => { | ||
@@ -23,7 +25,18 @@ try { | ||
exports.checkYarnInstall = exports.checkCommandInstall.bind(null, 'yarn --version'); | ||
const downloadRepos = (repos, targetPath, projectName) => { | ||
function reinitGit(localPath) { | ||
process.chdir(localPath); | ||
fs_1.default.rmSync(path_1.default.resolve('./.git'), { | ||
recursive: true | ||
}); | ||
child_process_1.execSync('git init'); | ||
} | ||
const downloadRepos = (repoObj, localPath, projectName) => { | ||
const spinner = ora_1.default('Downloading...').start(); | ||
git_clone_1.default(repos, targetPath, () => { | ||
spinner.stop(); | ||
console.log(` | ||
const { url, branch = '' } = repoObj; | ||
const params = { | ||
url, | ||
branch, | ||
localPath | ||
}; | ||
const successTemplate = ` | ||
✅ Boilerplate download successful | ||
@@ -34,5 +47,14 @@ | ||
Enjoy yourself! | ||
`); | ||
`; | ||
git_clone_1.default(params, (err) => { | ||
if (err === null) { | ||
reinitGit(localPath); | ||
spinner.stop(); | ||
console.log(successTemplate); | ||
} | ||
else { | ||
throw err; | ||
} | ||
}); | ||
}; | ||
exports.downloadRepos = downloadRepos; |
{ | ||
"name": "@blucass/create-project", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Create start project boilerplate", | ||
@@ -13,4 +13,3 @@ "bin": "bin/index.js", | ||
"release:minor": "standard-version --release-as minor", | ||
"release:major": "standard-version --release-as major", | ||
"prepublish": "yarn run build" | ||
"release:major": "standard-version --release-as major" | ||
}, | ||
@@ -20,3 +19,2 @@ "dependencies": { | ||
"fs-extra": "^9.1.0", | ||
"git-clone": "^0.1.0", | ||
"ora": "^5.4.0", | ||
@@ -23,0 +21,0 @@ "prompts": "^2.4.1", |
@@ -6,2 +6,2 @@ ## 创建项目模板脚手架 | ||
- main:脚手架 | ||
- <others>:项目模板 | ||
- [others]:项目模板 |
@@ -8,7 +8,2 @@ import prompts from 'prompts'; | ||
interface CommondOptions { | ||
skipInit?: boolean; | ||
preset?: []; | ||
} | ||
export default async function create() { | ||
@@ -36,4 +31,4 @@ const yarnInstalled = checkYarnInstall(); | ||
const projectType = await getProjectType(); | ||
type ReposType = keyof typeof Boilerplate_Repos; | ||
const repoUrl = Boilerplate_Repos[projectType as ReposType]; | ||
type BoilerplateType = keyof typeof Boilerplate_Repos; | ||
const repoUrl = Boilerplate_Repos[projectType as BoilerplateType]; | ||
@@ -49,7 +44,7 @@ if (!!repoUrl === false) return; | ||
name: 'projectName', | ||
message: '项目名称', | ||
message: '项目名称' | ||
}, | ||
{ | ||
onCancel: () => true, | ||
}, | ||
onCancel: () => true | ||
} | ||
); | ||
@@ -69,7 +64,7 @@ if (projectName.trim() === '') { | ||
{ | ||
title: 'React Lite', | ||
value: 'react-lite', | ||
description: '基于 create-react-app,支持自定义配置', | ||
}, | ||
], | ||
title: 'React Lite for PC', | ||
value: 'react-lite-pc', | ||
description: '基于 create-react-app,支持自定义配置' | ||
} | ||
] | ||
}); | ||
@@ -76,0 +71,0 @@ return projectType; |
export const Boilerplate_Repos = { | ||
'react-lite': '', | ||
'react-lite-pc': { | ||
url: 'git@github.com:wqcstrong/boilerplate.git', | ||
branch: 'react-lite-pc' | ||
} | ||
}; |
import { execSync } from 'child_process'; | ||
import clone from 'git-clone'; | ||
import fs from 'fs'; | ||
import ora from 'ora'; | ||
import chalk from 'chalk'; | ||
import clone from './git-clone'; | ||
import path from 'path'; | ||
@@ -17,14 +19,26 @@ export const checkCommandInstall = (command: string) => { | ||
null, | ||
'yarn --version', | ||
'yarn --version' | ||
); | ||
function reinitGit(localPath: string) { | ||
process.chdir(localPath); | ||
fs.rmSync(path.resolve('./.git'), { | ||
recursive: true | ||
}); | ||
execSync('git init'); | ||
} | ||
export const downloadRepos = ( | ||
repos: string, | ||
targetPath: string, | ||
projectName: string, | ||
repoObj: I.Repo, | ||
localPath: string, | ||
projectName: string | ||
) => { | ||
const spinner = ora('Downloading...').start(); | ||
clone(repos, targetPath, () => { | ||
spinner.stop(); | ||
console.log(` | ||
const { url, branch = '' } = repoObj; | ||
const params = { | ||
url, | ||
branch, | ||
localPath | ||
}; | ||
const successTemplate = ` | ||
✅ Boilerplate download successful | ||
@@ -35,4 +49,12 @@ | ||
Enjoy yourself! | ||
`); | ||
`; | ||
clone(params, (err) => { | ||
if (err === null) { | ||
reinitGit(localPath); | ||
spinner.stop(); | ||
console.log(successTemplate); | ||
} else { | ||
throw err; | ||
} | ||
}); | ||
}; |
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"rootDir": "src", | ||
@@ -17,3 +16,7 @@ "outDir": "bin", | ||
"esModuleInterop": true, | ||
"noImplicitAny": true | ||
"noImplicitAny": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
} | ||
}, | ||
@@ -20,0 +23,0 @@ "exclude": ["test"], |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12524
6
19
355
3
2
- Removedgit-clone@^0.1.0
- Removedgit-clone@0.1.0(transitive)