Skip to content

Commit

Permalink
add cli to main project
Browse files Browse the repository at this point in the history
we moved the cli code to hypestyle folder project
  • Loading branch information
lassejlv committed Jan 8, 2022
1 parent e65d4b5 commit 06a60bb
Show file tree
Hide file tree
Showing 16 changed files with 303 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ docs
examples
node_modules
src
cli
composer.json
composer.lock
SECURITY.md
todoList.md
gulpfile.js
composer.json
tasks.md
todoList.md
12 changes: 12 additions & 0 deletions cli/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
13 changes: 13 additions & 0 deletions cli/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
"env": {
"browser": true,
"es2021": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 13,
"sourceType": "module"
},
"rules": {
}
};
2 changes: 2 additions & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
package-lock.json
2 changes: 2 additions & 0 deletions cli/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.eslint.js
.editorconfig
7 changes: 7 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Hypestyle CLI

This is a **CLI** to generate a **Hypestyle** project.

To get started, run `npx hypestyle-cli@latest` to create a new project.

You can read the documentation for the CLI at [https://hypestyle.netlify.app/#/guide/cli/installation](https://hypestyle.netlify.app/#/guide/cli/installation).
28 changes: 28 additions & 0 deletions cli/my-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
This website was created with Hypestyle-cli
You find all the docs for Hypestyle
in the following link: https://hypestyle.netlify.app
Copyright (c) 2021, Hypestyle
-->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<!-- HypeStyle CSS -->
<link
rel="stylesheet"
href="https://unpkg.com/hypestyle@0.1.4/dist/css/hypestyle.min.css"
/>

<title>Yeah i using HypeStyle CSS!</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<h1>This was created by HypeStyle CLI</h1>

<script src="script.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions cli/my-app/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
*
*
*
This website was created with Hypestyle-cli
You find all the docs for Hypestyle
in the following link: https://hypestyle.netlify.app
Copyright (c) 2021, Hypestyle
*
*
*
*/

/*
You can start use your own css code if you want to make some changes
of components or add some new components.
*/
8 changes: 8 additions & 0 deletions cli/my-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "hypestyle-simple",
"version": "1.0.0",
"description": "This was made by @hypestyle-cli",
"scripts": {
"dev": "npx live-server --port=8080"
}
}
8 changes: 8 additions & 0 deletions cli/my-app/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
This website was created with Hypestyle-cli
You find all the docs for Hypestyle
in the following link: https://hypestyle.netlify.app
Copyright (c) 2021, Hypestyle
*/

console.log('Hypestyle is so cool!')
44 changes: 44 additions & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "hypestyle-cli",
"version": "3.0.0",
"description": "This is a cli tool to create a hyperstyle project",
"main": "src/index.js",
"bin": {
"create-hypestyle-app": "src/index.js"
},
"scripts": {
"start": "node src/index.js"
},
"keywords": [
"cli",
"hypestyle",
"hypestyle-cli"
],
"author": "",
"license": "ISC",
"dependencies": {
"@types/chalk-animation": "^1.6.1",
"@types/inquirer": "^8.1.3",
"chalk": "4.1.2",
"chalk-animation": "^1.6.0",
"fs-extra": "^10.0.0",
"inquirer": "^8.2.0",
"meow": "^10.1.2",
"rcnlx": "^1.2.1",
"semver": "^7.3.5"
},
"devDependencies": {
"eslint": "^8.4.1"
},
"directories": {
"test": "tests"
},
"repository": {
"type": "git",
"url": "git+https://github.com/hypestyle/cli.git"
},
"bugs": {
"url": "https://github.com/hypestyle/cli/issues"
},
"homepage": "https://github.com/hypestyle/cli#readme"
}
87 changes: 87 additions & 0 deletions cli/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env node
const inquirer = require('inquirer')
const fs = require('fs')
const chalkAnimation = require('chalk-animation')
const fse = require('fs-extra')
const chalk = require('chalk')

const CHOICES = fs.readdirSync(`${__dirname}/templates`)

console.log()
console.log(
`${chalk.greenBright('🌿 Welcome to hypestyle cli!')} ${chalk.redBright(
'Lets get you started!'
)}`
)
console.log()

const QUESTIONS = [
{
name: 'project-choice',
type: 'list',
message: 'What project would you like to create?',
choices: CHOICES,
},
{
name: 'project-name',
type: 'input',
message: 'What is the name of your project?',
validate: function (input) {
if (/^([A-Za-z\-\_\d])+$/.test(input)) return true
else
return 'Project name may only include letters, numbers, underscores and hashes.'
},
},
]

const CURR_DIR = process.cwd()

inquirer.prompt(QUESTIONS).then((answers) => {
const projectChoice = answers['project-choice']
const projectName = answers['project-name']

const templatePath = `${__dirname}/templates/${projectChoice}`

fs.mkdirSync(`${CURR_DIR}/${projectName}`)

createDirectoryContents(templatePath, projectName)

console.log()
console.log(`Done! Now run:`)
console.log()
console.log(`cd ${chalk.redBright(projectName)}`)
console.log(`npm run ${chalk.blueBright('dev')}`)
console.log()
})

function createDirectoryContents(templatePath, newProjectPath) {
const filesToCreate = fs.readdirSync(templatePath)

filesToCreate.forEach((file) => {
const origFilePath = `${templatePath}/${file}`

// get stats about the current file
const stats = fs.statSync(origFilePath)

if (stats.isFile()) {
const contents = fs.readFileSync(origFilePath, 'utf8')

const writePath = `${CURR_DIR}/${newProjectPath}/${file}`
fs.writeFileSync(writePath, contents, 'utf8')
}
})
}

const stats = fs.statSync(`${__dirname}/templates`)

if (stats.isFile()) {
const contents = fs.readFileSync(origFilePath, 'utf8')

// Rename
if (file === '.npmignore') file = '.gitignore'

// get folders in all templates

const writePath = `${CURR_DIR}/${newProjectPath}/${file}/${folder} `
fs.writeFileSync(writePath, contents, 'utf8')
}
28 changes: 28 additions & 0 deletions cli/src/templates/hypestyle-default/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
This website was created with Hypestyle-cli
You find all the docs for Hypestyle
in the following link: https://hypestyle.netlify.app
Copyright (c) 2021, Hypestyle
-->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<!-- HypeStyle CSS -->
<link
rel="stylesheet"
href="https://unpkg.com/hypestyle@0.1.4/dist/css/hypestyle.min.css"
/>

<title>Yeah i using HypeStyle CSS!</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<h1>This was created by HypeStyle CLI</h1>

<script src="script.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions cli/src/templates/hypestyle-default/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
*
*
*
This website was created with Hypestyle-cli
You find all the docs for Hypestyle
in the following link: https://hypestyle.netlify.app
Copyright (c) 2021, Hypestyle
*
*
*
*/

/*
You can start use your own css code if you want to make some changes
of components or add some new components.
*/
8 changes: 8 additions & 0 deletions cli/src/templates/hypestyle-default/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "hypestyle-simple",
"version": "1.0.0",
"description": "This was made by @hypestyle-cli",
"scripts": {
"dev": "npx live-server --port=8080"
}
}
8 changes: 8 additions & 0 deletions cli/src/templates/hypestyle-default/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
This website was created with Hypestyle-cli
You find all the docs for Hypestyle
in the following link: https://hypestyle.netlify.app
Copyright (c) 2021, Hypestyle
*/

console.log('Hypestyle is so cool!')

0 comments on commit 06a60bb

Please sign in to comment.