Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blucass/create-project

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blucass/create-project - npm Package Compare versions

Comparing version 0.5.1 to 0.5.3

186

dist/index.js
#!/usr/bin/env node
'use strict';
var __awaiter =
(this && this.__awaiter) ||
function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P
? value
: new P(function (resolve) {
resolve(value);
});
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const prompts_1 = __importDefault(require("prompts"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const path_1 = __importDefault(require("path"));
const utils_1 = require("./utils");
const repos_1 = require("./repos");
function create() {
return __awaiter(this, void 0, void 0, function* () {
const yarnInstalled = (0, utils_1.checkYarnInstall)();
if (!yarnInstalled) {
console.log('yarn 不存在');
return;
}
}
function rejected(value) {
try {
step(generator['throw'](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done
? resolve(result.value)
: adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
const realpath = yield fs_extra_1.default.realpath(process.cwd());
let isExisted = false;
let projectName = '';
let projectPath = '';
do {
projectName = yield getProjectName();
projectPath = path_1.default.join(realpath, projectName);
isExisted = fs_extra_1.default.pathExistsSync(projectPath);
if (isExisted === true) {
console.warn(`${projectName} 文件夹已存在,请重新输入`);
}
} while (isExisted === true);
const projectType = yield getProjectType();
const repoUrl = repos_1.Boilerplate_Repos[projectType];
if (!!repoUrl === false)
return;
(0, utils_1.downloadRepos)(repoUrl, projectPath, projectName);
});
};
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, '__esModule', { value: true });
const prompts_1 = __importDefault(require('prompts'));
const fs_extra_1 = __importDefault(require('fs-extra'));
const path_1 = __importDefault(require('path'));
const utils_1 = require('./utils');
const repos_1 = require('./repos');
function create() {
return __awaiter(this, void 0, void 0, function* () {
const yarnInstalled = utils_1.checkYarnInstall();
if (!yarnInstalled) {
console.log('yarn 不存在');
return;
}
const realpath = yield fs_extra_1.default.realpath(process.cwd());
let isExisted = false;
let projectName = '';
let projectPath = '';
do {
projectName = yield getProjectName();
projectPath = path_1.default.join(realpath, projectName);
isExisted = fs_extra_1.default.pathExistsSync(projectPath);
if (isExisted === true) {
console.warn(`${projectName} 文件夹已存在,请重新输入`);
}
} while (isExisted === true);
const projectType = yield getProjectType();
const repoUrl = repos_1.Boilerplate_Repos[projectType];
if (!!repoUrl === false) return;
utils_1.downloadRepos(repoUrl, projectPath, projectName);
});
}
exports.default = create;
function getProjectName() {
return __awaiter(this, void 0, void 0, function* () {
const { projectName = '' } = yield prompts_1.default(
{
type: 'text',
name: 'projectName',
message: '项目名称'
},
{
onCancel: () => true
}
);
if (projectName.trim() === '') {
process.exit();
}
return projectName.trim();
});
return __awaiter(this, void 0, void 0, function* () {
const { projectName = '' } = yield (0, prompts_1.default)({
type: 'text',
name: 'projectName',
message: '项目名称'
}, {
onCancel: () => true
});
if (projectName.trim() === '') {
process.exit();
}
return projectName.trim();
});
}
function getProjectType() {
return __awaiter(this, void 0, void 0, function* () {
const { projectType } = yield prompts_1.default({
type: 'select',
name: 'projectType',
message: '选择项目模板',
choices: [
{
title: 'React(cra) for PC',
value: 'react-lite-pc',
description: '基于 create-react-app,支持自定义配置'
},
{
title: 'React(vite) for PC',
value: 'react-vite-pc',
description: '基于 Vite 封装'
},
{
title: 'React(vite) for Mobile',
value: 'react-vite-mobile',
description: '基于 Vite 封装'
}
]
return __awaiter(this, void 0, void 0, function* () {
const { projectType } = yield (0, prompts_1.default)({
type: 'select',
name: 'projectType',
message: '选择项目模板',
choices: [
{
title: 'React(cra) B端 ',
value: 'react-lite-pc',
description: '基于 create-react-app,支持自定义配置'
},
{
title: 'React(vite) B端',
value: 'react-vite-pc',
description: '技术栈:Vite + React + antd + axios'
},
{
title: 'React(vite) C端',
value: 'react-vite-mobile',
description: '技术栈: Vite + React + antd-mobile + TailwindCSS + axios'
}
]
});
return projectType;
});
return projectType;
});
}
create();
process.on('rejectionHandled', (error) => {
throw error;
throw error;
});
export declare const Boilerplate_Repos: {
'react-lite-pc': {
url: string;
branch: string;
};
'react-vite-pc': {
url: string;
branch: string;
};
'react-vite-mobile': {
url: string;
branch: string;
};
'react-lite-pc': {
url: string;
branch: string;
};
'react-vite-pc': {
url: string;
branch: string;
};
'react-vite-mobile': {
url: string;
branch: string;
};
};

@@ -1,17 +0,17 @@

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Boilerplate_Repos = void 0;
exports.Boilerplate_Repos = {
'react-lite-pc': {
url: 'git@github.com:wqcstrong/boilerplate.git',
branch: 'react-lite-pc'
},
'react-vite-pc': {
url: 'git@github.com:wqcstrong/boilerplate.git',
branch: 'react-vite-pc'
},
'react-vite-mobile': {
url: 'git@github.com:wqcstrong/boilerplate.git',
branch: 'react-vite-mobile'
}
'react-lite-pc': {
url: 'git@github.com:wqcstrong/boilerplate.git',
branch: 'react-lite-pc'
},
'react-vite-pc': {
url: 'git@github.com:wqcstrong/boilerplate.git',
branch: 'react-vite-pc'
},
'react-vite-mobile': {
url: 'git@github.com:wqcstrong/boilerplate.git',
branch: 'react-vite-mobile'
}
};
interface CloneObject {
url: string;
branch?: string;
localPath: string;
url: string;
branch?: string;
localPath: string;
}
export default function gitClone(
params: CloneObject,
callback: (err: Error | null) => void
): void;
export default function gitClone(params: CloneObject, callback: (err: Error | null) => void): void;
export {};

@@ -1,17 +0,17 @@

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const child_process_1 = require('child_process');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process");
function gitClone(params, callback) {
const { url, branch = '', localPath } = params;
const args = ['git clone'];
if (!!branch === true) {
args.push(`-b ${branch}`);
}
args.push('--');
args.push(url);
args.push(localPath);
child_process_1.exec(args.join(' '), (err) => {
callback && callback(err);
});
const { url, branch = '', localPath } = params;
const args = ['git clone'];
if (!!branch === true) {
args.push(`-b ${branch}`);
}
args.push('--');
args.push(url);
args.push(localPath);
(0, child_process_1.exec)(args.join(' '), (err) => {
callback && callback(err);
});
}
exports.default = gitClone;
export declare const checkCommandInstall: (command: string) => boolean;
export declare const checkYarnInstall: () => boolean;
export declare const downloadRepos: (
repoObj: I.Repo,
localPath: string,
projectName: string
) => void;
export declare const downloadRepos: (repoObj: I.Repo, localPath: string, projectName: string) => void;

@@ -1,44 +0,40 @@

'use strict';
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, '__esModule', { value: true });
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.downloadRepos = exports.checkYarnInstall = exports.checkCommandInstall = void 0;
const child_process_1 = require('child_process');
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 child_process_1 = require("child_process");
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) => {
try {
child_process_1.execSync(command, { stdio: 'ignore' });
return true;
} catch (e) {
return false;
}
try {
(0, child_process_1.execSync)(command, { stdio: 'ignore' });
return true;
}
catch (e) {
return false;
}
};
exports.checkCommandInstall = checkCommandInstall;
exports.checkYarnInstall = exports.checkCommandInstall.bind(
null,
'yarn --version'
);
exports.checkYarnInstall = exports.checkCommandInstall.bind(null, 'yarn --version');
function reinitGit(localPath) {
process.chdir(localPath);
fs_1.default.rmSync(path_1.default.resolve('./.git'), {
recursive: true
});
child_process_1.execSync('git init');
process.chdir(localPath);
fs_1.default.rmSync(path_1.default.resolve('./.git'), {
recursive: true
});
(0, child_process_1.execSync)('git init');
}
const downloadRepos = (repoObj, localPath, projectName) => {
const spinner = ora_1.default('Downloading...').start();
const { url, branch = '' } = repoObj;
const params = {
url,
branch,
localPath
};
const successTemplate = `
const spinner = (0, ora_1.default)('Downloading...').start();
const { url, branch = '' } = repoObj;
const params = {
url,
branch,
localPath
};
const successTemplate = `
✅ Boilerplate download successful

@@ -50,12 +46,13 @@

`;
git_clone_1.default(params, (err) => {
if (err === null) {
reinitGit(localPath);
spinner.stop();
console.log(successTemplate);
} else {
throw err;
}
});
(0, 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.5.1",
"version": "0.5.3",
"description": "Create start project boilerplate",

@@ -9,8 +9,12 @@ "bin": "dist/index.js",

"build": "tsc",
"test": "node dist/index.js",
"test": "yarn build && node dist/index.js",
"commit": "git-cz",
"release:patch": "standard-version --release-as patch",
"release:minor": "standard-version --release-as minor",
"release:major": "standard-version --release-as major"
"release:major": "standard-version --release-as major",
"prepublishOnly": "yarn build"
},
"files": [
"dist"
],
"author": {

@@ -24,2 +28,6 @@ "name": "Blucas Wu",

},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"homepage": "https://github.com/wqcstrong/boilerplate",

@@ -26,0 +34,0 @@ "dependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc