Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/sms server #82

Merged
merged 7 commits into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
"inquirer": "^8.2.0",
"ncp": "^2.0.0",
"rimraf": "^3.0.2",
"shelljs": "^0.8.2",
"yargs": "^17.3.0"
"shelljs": "^0.8.5",
"yargs": "^17.3.1"
},
"devDependencies": {
"@types/inquirer": "^8.1.3",
"@types/node": "^16.11.12",
"@types/shelljs": "^0.8.9",
"@types/yargs": "^17.0.4",
"@types/inquirer": "^8.2.0",
"@types/node": "^17.0.13",
"@types/shelljs": "^0.8.11",
"@types/yargs": "^17.0.8",
"ts-node": "^10.3.0",
"typescript": "^4.5.3"
"typescript": "^4.5.5"
},
"git repository": "https://github.com/open-template-hub/open-template-hub-server-generator",
"repository": {
Expand Down
3 changes: 3 additions & 0 deletions src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const TemplateType = {
FileStorageServer: '4',
AnalyticsServer: '5',
MailServer: '6',
SmsServer: '7'
};

export const TEMPLATE_HUB_URL = 'https://github.com/open-template-hub';
Expand All @@ -18,6 +19,7 @@ export const ProjectName = {
FileStorageServer: 'file-storage-server-template',
AnalyticsServer: 'analytics-server-template',
MailServer: 'mail-server-template',
SmsServer: 'sms-server-template',
};

export const PackageName = {
Expand All @@ -27,4 +29,5 @@ export const PackageName = {
FileStorageServer: 'file-storage-server-template',
AnalyticsServer: 'analytics-server-template',
MailServer: 'mail-server-template',
SmsServer: 'sms-server-template',
};
18 changes: 16 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ const QUESTIONS = [
' 4) File Storage Server \n' +
' 5) Analytics Server \n' +
' 6) Mail Server \n' +
' 7) Sms Server \n' +
' Please enter a server type you want to generate: ',
when: () => yargs().argv,
validate: (input: string) => {
if (/^[1 | 2 | 3 | 4 | 5 | 6]$/.test(input)) return true;
if (/^[1 | 2 | 3 | 4 | 5 | 6 | 7]$/.test(input)) return true;
else
return 'Please enter correct server type. Server type can be 1, 2, 3, 4, 5 and 6.';
return 'Please enter correct server type. Server type can be 1, 2, 3, 4, 5, 6 and 7.';
},
},
{
Expand Down Expand Up @@ -142,6 +143,10 @@ const updateProjectName = (
repoConfig.projectName = ProjectName.MailServer;
repoConfig.packageName = PackageName.MailServer;
break;
case TemplateType.SmsServer:
repoConfig.projectName = ProjectName.SmsServer;
repoConfig.packageName = PackageName.SmsServer;
break;
}

let oldPath = path.join(targetPath, repoConfig.projectName);
Expand Down Expand Up @@ -231,6 +236,15 @@ const cloneTemplate = (targetPath: string, templateType: string) => {
'/' +
ProjectName.MailServer;
break;
case TemplateType.SmsServer:
cmd =
clone +
BRANCH_NAME +
' ' +
TEMPLATE_HUB_URL +
'/' +
ProjectName.SmsServer;
break;
}
console.log('command: ', cmd);
const result = shell.exec(cmd);
Expand Down