Skip to content

Commit

Permalink
Merged v1.2 | Shorky
Browse files Browse the repository at this point in the history
  • Loading branch information
iTzSharkSV authored Dec 21, 2021
2 parents e492a4f + 25afc5a commit 38a9676
Show file tree
Hide file tree
Showing 48 changed files with 808 additions and 127 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
github: [iTzSharkSV]
patreon: SharkSV
ko_fi: SharkSV
9 changes: 4 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@

<!--- Put an `x` in all the boxes that apply: -->

- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
- [ ] My code follows the code style of this project.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

## Featured changes

Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
- run: yarn install
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
2 changes: 1 addition & 1 deletion .prettierrc.json → .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"trailingComma": "none",
"arrowParens": "avoid",
"arrowParens": "always",
"singleQuote": true,
"printWidth": 80,
"useTabs": true,
Expand Down
14 changes: 9 additions & 5 deletions Bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@

const info = require('../Lib/Info.js');
const cli = require('../Lib/Cli');
const Init = require('../Lib/Init');
const Log = require('../Lib/Utils/Log');
const cProject = require('../Lib/Init/cProject');
const Prompt = require('../Lib/Init/Prompt');

const input = cli.input;
const flags = cli.flags;
const { clear, debug } = flags;
const { clear } = flags;

Init = async () => {
options = await Prompt();
info();
await cProject(options);
};

(async () => {
info({ clear });
// Commands
input.includes(`help`) && cli.showHelp(0);
input.includes(`init`) && Init();
// Flags
debug && Log('warning', 'You Sneaky!') & console.table(flags);
})();
2 changes: 1 addition & 1 deletion Docs/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This Code of Conduct applies within all project spaces, and it also applies when

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainer [SharkSV](mailto:support@SharkSV.engineer). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainer [Shorky](mailto:SharkSV@outlook.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

Expand Down
2 changes: 1 addition & 1 deletion Docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ These guidelines will ensure the pull request process is easy and traceable for
1. Increase the version number in package.json and create new entry at the beginning of [CHANGELOG](../CHANGELOG.md). Entries in the changelog file should be quick bullet points of the items changed, not just commit messages. The versioning scheme we use is [SemVer](http://semver.org/).
2. Submit the pull request. A maintainer will review the changes contact you with any followup actions.

#### Contact [SharkSV](mailto:support@SharkSV.engineer) with any questions
#### Contact [Shorky](mailto:SharkSV@outlook.com) with any questions
2 changes: 1 addition & 1 deletion Docs/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

If there are any vulnerability in this project, don't hesitate to _report them_.

1. Contact project maintainer [SharkSV](mailto:support@SharkSV.engineer).
1. Contact project maintainer [Shorky](mailto:SharkSV@outlook.com).
2. Describe the vulnerability.

- If you have a fix, explain or attach it.
Expand Down
6 changes: 0 additions & 6 deletions Lib/Cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ const flags = {
alias: `c`,
desc: `Clear the console`
},
debug: {
type: `boolean`,
default: false,
alias: `d`,
desc: `Print debug info`
},
version: {
type: `boolean`,
alias: `v`,
Expand Down
6 changes: 4 additions & 2 deletions Lib/Info.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const welcome = require('cli-welcome');
const pkg = require('../package.json');
const unhandled = require('cli-handle-unhandled');

module.exports = ({ clear = true }) => {
Info = () => {
unhandled();
welcome({
title: `Hyper`,
Expand All @@ -12,6 +12,8 @@ module.exports = ({ clear = true }) => {
bgColor: '#36BB09',
color: '#000000',
bold: true,
clear
clear: true
});
};

module.exports = Info;
94 changes: 51 additions & 43 deletions Lib/Init/Prompt.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,61 @@
const inquirer = require('inquirer');

module.exports = PFO = async options => {
// Options:
Prompt = async (options) => {
// Placeholders:
const _Name = 'Author';
const _Email = 'me@Example.com';
const questions = [];

if (!options.name) {
questions.push({
type: 'input',
name: 'name',
message: "Author's Name",
default: _Name
});
}

if (!options.email) {
questions.push({
type: 'input',
name: 'email',
message: 'Public Email',
default: _Email
});
}

if (!options.git) {
questions.push({
type: 'confirm',
name: 'git',
message: 'Initilize Git?',
default: true
});
}

if (!options.license) {
questions.push({
type: 'confirm',
name: 'license',
message: 'Create a License?',
default: true
});
}
const _Template = 'Javascript';

// Questions
let Template, Name, Email, Git, License;

Template = {
type: 'list',
name: 'template',
message: 'Project Template:',
choices: ['Javascript', 'Typescript'],
default: _Template
};

Name = {
type: 'input',
name: 'name',
message: "Author's Name:",
default: _Name
};

Email = {
type: 'input',
name: 'email',
message: 'Public Email:',
default: _Email
};

Git = {
type: 'confirm',
name: 'git',
message: 'Initilize Git?',
default: true
};

License = {
type: 'confirm',
name: 'license',
message: 'Create a License?',
default: true
};

const questions = [Template, Name, Email, Git, License];
const answers = await inquirer.prompt(questions);

return {
...options,
name: options.name || answers.name,
email: options.email || answers.email,
git: options.git || answers.git,
license: options.license || answers.license
Template: answers.template,
Name: answers.name,
Email: answers.email,
Git: answers.git,
License: answers.license
};
};

module.exports = Prompt;
92 changes: 50 additions & 42 deletions Lib/Init/cProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@ const { promisify } = require('util');
const { projectInstall } = require('pkg-install');

// Imports:
const Log = require('../Utils/Log');
const Print = require('../Utils/Print');
const cli = require('../Cli');
const flags = cli.flags;
const { runInstall } = flags;

const copy = promisify(ncp);
const writeFile = promisify(fs.writeFile);

// Options:
const templateDir = path.join(__dirname, '../../Template');
// Global variables:
const currentDir = process.cwd();

// Methods:
// Functions:
copyTemplateFiles = async () => {
const { Template } = options;
const templateDir = path.join(__dirname, '../../Templates', Template);
return copy(templateDir, currentDir, {
clobber: true
});
};

createLicense = async options => {
createLicense = async () => {
const { Name, Email } = options;
const targetPath = path.join(currentDir, 'LICENSE');
const licenseContent = mitLicense.licenseText
.replace('<year>', new Date().getFullYear())
.replace('<copyright holders>', `${options.name} (${options.email})`);
.replace('<copyright holders>', `${Name} (${Email})`);
return writeFile(targetPath, licenseContent, 'utf8');
};

Expand All @@ -45,41 +45,49 @@ initGit = async () => {
: Promise.resolve();
};

module.exports = createProject = async options => {
const Tasks = new Listr(
[
{
title: 'Copy project files',
task: () => copyTemplateFiles()
},
{
title: 'Initialize git',
task: () => initGit(),
enabled: () => options.git
},
{
title: 'Create a license',
task: () => createLicense(options),
enabled: () => options.license
},
{
title: 'Install dependencies',
task: () =>
projectInstall({
cwd: currentDir
}),
skip: () =>
!runInstall
? 'Pass -i to automatically install dependencies'
: undefined
}
],
createProject = async (options) => {
const { Git, License } = options;
const flags = cli.flags;
const { runInstall } = flags;

const Todo = [
{
title: 'Copy project files',
task: () => copyTemplateFiles(options)
},
{
title: 'Initialize git',
task: () => initGit(),
enabled: () => Git
},
{
title: 'Create a license',
task: () => createLicense(options),
enabled: () => License
},
{
exitOnError: false
title: 'Install dependencies',
task: () =>
projectInstall({
cwd: currentDir
}),
skip: () =>
!runInstall
? 'Pass -i to automatically install dependencies'
: undefined
}
);
];

await Tasks.run();
Log('success', 'Project initilized successfully!');
return true;
const Tasks = new Listr(Todo, {
exitOnError: false
});

try {
await Tasks.run();
Print('success', 'Project initilized successfully!');
} catch (error) {
Print('error', 'An error occured while initializing the project.');
}
};

module.exports = createProject;
12 changes: 0 additions & 12 deletions Lib/Init/index.js

This file was deleted.

8 changes: 5 additions & 3 deletions Lib/Utils/Log.js → Lib/Utils/Print.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const alert = require('cli-alerts');

module.exports = (funcType, info) => {
let name = '';
Print = (funcType, info) => {
let name;

switch (funcType) {
case 'success':
Expand All @@ -11,7 +11,7 @@ module.exports = (funcType, info) => {
name = 'Fail';
break;
case 'warning':
name = 'Log';
name = 'Attention';
break;
default:
name = 'Info';
Expand All @@ -23,3 +23,5 @@ module.exports = (funcType, info) => {
msg: info
});
};

module.exports = Print;
Loading

0 comments on commit 38a9676

Please sign in to comment.