Skip to content

Commit

Permalink
Merge pull request #37 from open-template-hub/develop
Browse files Browse the repository at this point in the history
Dev to Master
  • Loading branch information
fatihturker authored Dec 14, 2021
2 parents 0cc564c + 9739f89 commit 1d253fc
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ updates:
target-branch: 'workflow/dependency-update'
labels:
- 'workflow'
milestone: 1
milestone: 2
2 changes: 1 addition & 1 deletion .github/workflows/cron-dependency-checker-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Npm Outdated
run: npm run outdated
- name: Build
run: npm run buildProd
run: npm run build

- name: Git Commit and Push
run: |
Expand Down
5 changes: 4 additions & 1 deletion .run/outdated.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="outdated" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="outdated" />
<command value="run" />
<scripts>
<script value="outdated" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
Expand Down
5 changes: 2 additions & 3 deletions NPM-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
</p>

<h1 align="center">
Open Template Hub - UI Generator v2
Open Template Hub - UI Generator v4
</h1>

[![GitHubRepo](https://img.shields.io/badge/GitHub-Repository-24292e.svg?style=for-the-badge&logo=github)](https://github.com/open-template-hub/app-generator)
[![SonarCloud](https://img.shields.io/sonar/quality_gate/open-template-hub_app-generator?server=https%3A%2F%2Fsonarcloud.io&label=Sonar%20Cloud&style=for-the-badge&logo=sonarcloud)](https://sonarcloud.io/dashboard?id=open-template-hub_app-generator)
[![BTC](https://img.shields.io/badge/Donate-BTC-ORANGE?color=F5922F&style=for-the-badge&logo=bitcoin)](https://commerce.coinbase.com/checkout/8313af5f-de48-498d-b2cb-d98819ca7d5e)

Command line interface generator of the user interfaces at [Open Template Hub](https://github.com/open-template-hub)
Command-line interface generator of the servers at [Open Template Hub](https://github.com/open-template-hub)

Available UI types are:

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</p>

<h1 align="center">
Open Template Hub - UI Generator v2
Open Template Hub - UI Generator v4
</h1>

[![Version](https://img.shields.io/npm/v/@open-template-hub/app-generator?color=CB3837&style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@open-template-hub/app-generator)
Expand All @@ -16,9 +16,8 @@ Open Template Hub - UI Generator v2
[![LastCommit](https://img.shields.io/github/last-commit/open-template-hub/app-generator?color=43b043&style=for-the-badge)](https://github.com/open-template-hub/app-generator/commits/master)
[![Release](https://img.shields.io/github/release/open-template-hub/app-generator?include_prereleases&color=43b043&style=for-the-badge)](https://github.com/open-template-hub/app-generator/releases)
[![SonarCloud](https://img.shields.io/sonar/quality_gate/open-template-hub_app-generator?server=https%3A%2F%2Fsonarcloud.io&label=Sonar%20Cloud&style=for-the-badge&logo=sonarcloud)](https://sonarcloud.io/dashboard?id=open-template-hub_app-generator)
[![BTC](https://img.shields.io/badge/Donate-BTC-ORANGE?color=F5922F&style=for-the-badge&logo=bitcoin)](https://commerce.coinbase.com/checkout/8313af5f-de48-498d-b2cb-d98819ca7d5e)

Command line interface generator of the user interfaces at [Open Template Hub](https://github.com/open-template-hub)
Command-line interface generator of the user interfaces at [Open Template Hub](https://github.com/open-template-hub)

Available UI types are:

Expand Down
36 changes: 36 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@open-template-hub/app-generator",
"description": "Command-line interface generator of the user interfaces at Open Template Hub",
"website": "https://opentemplatehub.com/product/generator/app-generator",
"repository": "https://github.com/open-template-hub/app-generator",
"logo": "https://raw.githubusercontent.com/open-template-hub/open-template-hub.github.io/master/assets/logo/generator/server-generator-logo.png",
"keywords": [
"ui",
"app",
"application",
"rest",
"node",
"nodejs",
"typescript",
"cli",
"template",
"ui template",
"angular",
"angular template",
"angular project example",
"react",
"react template",
"react project example",
"react native",
"react native template",
"react native project example",
"application generator",
"ui example",
"application template generator",
"open template hub",
"angular web",
"react native mobile",
"angular web application",
"react native mobile application"
]
}
29 changes: 20 additions & 9 deletions dependency-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ console.log(
'\n' +
'\n' +
'<h1 align="center">\n' +
'Open Template Hub - UI Generator v2\n' +
'Open Template Hub - UI Generator v4\n' +
' <br/>\n' +
'(outdated packages)\n' +
'</h1>\n' +
Expand All @@ -26,25 +26,36 @@ for ( const line of lines ) {
if ( line.length === 0 ) {
continue;
}

if ( lines.indexOf( line ) === 0 ) {
columnIndexes[ 0 ] = line.indexOf( 'Current' );
columnIndexes[ 1 ] = line.indexOf( 'Wanted' ) + 3;
columnIndexes[ 2 ] = line.indexOf( 'Latest' ) + 6;
columnIndexes[ 3 ] = line.indexOf( 'Location' ) + 9;
}

let modifiedLine = line;

let modifiedLine = '';
if ( columnIndexes [ 0 ] >= 0 ) {
for ( const columnIndex of columnIndexes ) {
modifiedLine = modifiedLine.substring( 0, columnIndex ) + ' | ' + modifiedLine.substring( columnIndex, modifiedLine.length );
const stringParts = line.split( /(\s+)/ );

modifiedLine += '| ';

for ( let part of stringParts ) {
if ( part.match( /\s+/ ) ) {
modifiedLine += ' | ';
} else {
modifiedLine += part;
}
}
console.log( '| ' + modifiedLine + ' |' );

modifiedLine += ' |';

console.log( modifiedLine );
} else {
console.log( modifiedLine );
}

if ( lines.indexOf( line ) === 0 ) {
console.log( '| --- | --- | --- | --- | --- |' );
}
Expand Down
4 changes: 1 addition & 3 deletions docs/OUTDATED.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@


<h1 align="center">
Open Template Hub - UI Generator v2
Open Template Hub - UI Generator v4
<br/>
(outdated packages)
</h1>

Following packages are not updated in the develop branch yet. So, if you want to update outdated packages on your own risk, update the package.json and install dependencies.

| Package | Current | Wanted | Latest | Location |
| --- | --- | --- | --- | --- |

<table align="right"><tr><td><a href="https://opentemplatehub.com"><img src="https://raw.githubusercontent.com/open-template-hub/open-template-hub.github.io/master/assets/logo/brand-logo.png" width="50px" alt="oth"/></a></td><td><b>Open Template Hub © 2021</b></td></tr></table>

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@open-template-hub/app-generator",
"description": "CLI UI generator of UI Templates on Open Template Hub",
"description": "Command-line interface generator of the user interfaces at Open Template Hub",
"version": "3.0.1",
"license": "MIT",
"preferGlobal": true,
Expand All @@ -11,25 +11,25 @@
"outdated": "node dependency-checker.ts > docs/OUTDATED.md"
},
"bin": {
"open-template-hub-app-generator": "dist/index.js"
"open-template-hub-app-generator": "dist/src/index.js"
},
"dependencies": {
"@types/ncp": "^2.0.4",
"@types/rimraf": "^3.0.0",
"chalk": "^4.1.0",
"inquirer": "^6.2.0",
"@types/ncp": "^2.0.5",
"@types/rimraf": "^3.0.2",
"colors": "^1.4.0",
"inquirer": "^8.2.0",
"ncp": "^2.0.0",
"rimraf": "^3.0.2",
"shelljs": "^0.8.2",
"yargs": "^12.0.1"
"yargs": "^17.2.1"
},
"devDependencies": {
"@types/inquirer": "^0.0.43",
"@types/node": "^10.17.50",
"@types/shelljs": "^0.8.0",
"@types/yargs": "^11.1.1",
"ts-node": "^7.0.1",
"typescript": "^3.9.7"
"@types/inquirer": "^8.1.2",
"@types/node": "^16.11.12",
"@types/shelljs": "^0.8.9",
"@types/yargs": "^17.0.4",
"ts-node": "^10.2.1",
"typescript": "^4.5.3"
},
"git repository": "https://github.com/open-template-hub/app-generator",
"repository": {
Expand Down
22 changes: 11 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* @description holds the project generator
*/

import chalk from 'chalk';
import colors from 'colors';
import * as fs from 'fs';
import * as inquirer from 'inquirer';
import { ncp } from 'ncp';
import * as path from 'path';
import rmdir from 'rimraf';
import * as shell from 'shelljs';
import yargs from 'yargs';
import yargs from 'yargs/yargs';
import { BRANCH_NAME, PackageName, ProjectName, TEMPLATE_HUB_URL, TemplateType, } from './constant';

// Questions
Expand All @@ -24,7 +24,7 @@ const QUESTIONS = [
' 2) Mobile Application \n' +
' 3) Company Profile UI \n' +
' Please enter the application type you want to generate: ',
when: () => !yargs.argv[ 'template' ],
when: () => yargs().argv,
validate: ( input: string ) => {
if ( /^[1 | 2| 3]$/.test( input ) ) return true;
else
Expand All @@ -35,7 +35,7 @@ const QUESTIONS = [
name: 'name',
type: 'input',
message: 'Project name: ',
when: () => !yargs.argv[ 'template' ],
when: () => yargs().argv,
validate: ( input: string ) => {
if ( /^([A-Za-z\-\_\d])+$/.test( input ) ) return true;
else
Expand All @@ -49,7 +49,7 @@ const CURR_DIR = process.cwd();

// prompts questions to user
inquirer.prompt( QUESTIONS ).then( ( answers ) => {
let userAnswers = Object.assign( {}, answers, yargs.argv );
let userAnswers = Object.assign( {}, answers, yargs().argv );

const projectName = userAnswers[ 'name' ];
const targetPath = path.join( CURR_DIR, projectName );
Expand All @@ -61,12 +61,12 @@ inquirer.prompt( QUESTIONS ).then( ( answers ) => {
const templateType = userAnswers[ 'template' ];

if ( !cloneTemplate( targetPath, templateType ) ) {
console.error( chalk.red( 'Can not clone the selected template.' ) );
console.error( colors.red( 'Can not clone the selected template.' ) );
return;
}

if ( !updateProjectName( targetPath, templateType, projectName ) ) {
console.error( chalk.red( 'Can not set the project name.' ) );
console.error( colors.red( 'Can not set the project name.' ) );
return;
}

Expand Down Expand Up @@ -192,8 +192,8 @@ const cloneTemplate = ( targetPath: string, templateType: string ) => {
*/
const showMessage = ( projectName: string ) => {
console.log( '' );
console.log( chalk.green( 'Done.' ) );
console.log( chalk.green( `Go into the project: cd ${ projectName }` ) );
console.log( colors.green( 'Done.' ) );
console.log( colors.green( `Go into the project: cd ${ projectName }` ) );
};

/**
Expand All @@ -204,7 +204,7 @@ const showMessage = ( projectName: string ) => {
const createProject = ( projectPath: string ) => {
if ( fs.existsSync( projectPath ) ) {
console.error(
chalk.red( `Folder ${ projectPath } exists. Delete or use another name.` )
colors.red( `Folder ${ projectPath } exists. Delete or use another name.` )
);
return false;
}
Expand Down Expand Up @@ -236,7 +236,7 @@ const postProcessNode = ( targetPath: string ) => {
return false;
}
} else {
console.error( chalk.red( 'No yarn or npm found. Cannot run installation.' ) );
console.error( colors.red( 'No yarn or npm found. Cannot run installation.' ) );
}

return true;
Expand Down

0 comments on commit 1d253fc

Please sign in to comment.