@area17/a17-generator
Advanced tools
Comparing version 0.1.16 to 1.0.0
#!/usr/bin/env node | ||
'use strict'; | ||
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
const chalk = require('chalk'); | ||
const spawn = require('cross-spawn'); | ||
const _ = require('lodash'); | ||
const readlineSync = require('readline-sync'); | ||
import child_process from 'child_process'; | ||
import chalk from 'chalk'; | ||
import path from 'path'; | ||
import readlineSync from 'readline-sync'; | ||
const processArgv = _.toArray(process.argv); | ||
const args = processArgv.slice(2); | ||
const appName = args[0]; | ||
import libs from '../src/libs.js'; | ||
import writePkgJson from '../src/writePkgJson.js'; | ||
import applicationOptions from '../src/applicationOptions.js'; | ||
import installPackages from '../src/installPackages.js'; | ||
import copySetupFiles from '../src/copySetupFiles.js'; | ||
import postInstall from '../src/postInstall.js'; | ||
import initialiseGit from '../src/initialiseGit.js'; | ||
// Main install process | ||
console.log(chalk.green('Start to install')); | ||
const processArgv = [...process.argv]; | ||
const args = processArgv.slice(2); | ||
const maxSteps = 5; | ||
const printStep = (str) => { | ||
console.log(chalk.magenta(`\n[${ currentStep++ }/${ maxSteps }] ${ str }`)); | ||
}; | ||
let currentStep = 1; | ||
let appName = args[0] === undefined ? path.basename(process.cwd()) : args[0]; | ||
console.log(`Creating '${appName}' at ${process.cwd()} \n`); | ||
console.clear(); | ||
console.log(` | ||
17771 /7A | ||
/77777/ /A7/ | ||
/A777777/ A7/ | ||
A77A/A777/ 171 | ||
A777/ /A77A/ 171 | ||
1777/ /777A 17A | ||
17777777777777A /7A | ||
/777A1111111A7771 /7A/ | ||
/777A 17771 /77/ | ||
A777/ 7777/ A71 | ||
`); | ||
console.log(chalk.blue(`[1/3] Create package.json file`)); | ||
writePkgJson(); | ||
console.log(chalk.blue(`[2/3] Install packages(This might take some time)`)); | ||
installPackage(); | ||
console.log(chalk.blue(`[3/3] Generate boilerplate files`)); | ||
init(); | ||
console.log(chalk.green('Finished, enjoy!')); | ||
// End of install process | ||
// Generate package.json file for the project | ||
function writePkgJson() { | ||
if(fs.existsSync(path.join(process.cwd(),'package.json'))) { | ||
let answer = readlineSync.question('Existing package.json is found, continue will overwrite, are you sure?(y/n)'); | ||
if(answer !== 'y') { | ||
process.exit(); | ||
} | ||
} | ||
const packageJson = { | ||
name: appName, | ||
version: '0.1.0', | ||
private: true, | ||
dependencies: { | ||
'@area17/a17-helpers': '^2.0.2', | ||
}, | ||
devDependencies: { | ||
'@area17/a17-boilerplate': '^7.1.3' | ||
}, | ||
scripts: { | ||
'init': 'a17-bp init' | ||
}, | ||
engines: { | ||
'node': '>= 10.15.0', | ||
'npm': '>= 6.4.1' | ||
} | ||
}; | ||
fs.writeFileSync( | ||
path.join(process.cwd(),'package.json'), | ||
JSON.stringify(packageJson, null, 2) | ||
); | ||
console.log(chalk.green('package.json is created')); | ||
printStep('Choose application name'); | ||
console.log(chalk.cyan(`\nIs "${ chalk.white(appName) }" your application name?`)); | ||
if (readlineSync.keyInSelect(['Yes'], null, { cancel: 'No'}) !== 0) { | ||
appName = readlineSync.question('What is your application name? ', { | ||
defaultInput: appName, | ||
}); | ||
} | ||
// Install necessary packages (a17-helpers / a17-scripts) | ||
function installPackage() { | ||
let result = spawn.sync('npm', ['install'], {stdio: 'inherit'}); | ||
printStep('First, lets choose application options'); | ||
const installOptions = applicationOptions(); | ||
if(result.status === 1) { | ||
console.log(chalk.red('Exit with an error')); | ||
process.exit(); | ||
} else { | ||
console.log(chalk.green('Packages are successfully installed')); | ||
} | ||
} | ||
console.log(chalk.green(`\nCreating '${ chalk.white(appName) }' at ${process.cwd()}`)); | ||
// Initialize files (using a17-script init function) | ||
function init() { | ||
console.log(`Start to initialize project`); | ||
let result = spawn.sync('npm', ['run','init'], {stdio: 'inherit'}); | ||
printStep('Create package.json file'); | ||
writePkgJson(appName, installOptions); | ||
if(result.status === 1) { | ||
console.log(chalk.red('Exit with an error')); | ||
process.exit(); | ||
} else { | ||
console.log(chalk.green('Files are generated')); | ||
} | ||
if (installOptions.git.init) { | ||
printStep('Initialise Git'); | ||
initialiseGit(installOptions); | ||
} | ||
printStep('Install packages (This might take some time)'); | ||
installPackages(installOptions); | ||
printStep('Copy setup files and folders'); | ||
copySetupFiles(installOptions, processArgv, appName); | ||
postInstall(installOptions, appName); |
{ | ||
"name": "@area17/a17-generator", | ||
"version": "0.1.16", | ||
"description": "The generator of A17 Bolierplate", | ||
"version": "1.0.0", | ||
"description": "A17 Generator is used to quickly install A17 FE libraries", | ||
"author": "A17 <dev@area17.com> (https://area17.com/)", | ||
"license": "MIT", | ||
"type": "module", | ||
"bin": { | ||
"a17-generator": "bin/a17_generator.js" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://code.area17.com/a17/a17-generator" | ||
"url": "https://github.com/area17/a17-generator" | ||
}, | ||
"author": "A17 <dev@area17.com> (https://area17.com/)", | ||
"license": "MIT", | ||
"dependencies": { | ||
"chalk": "^2.1.0", | ||
"cross-spawn": "^5.1.0", | ||
"fs-extra": "^4.0.2", | ||
"lodash": "^4.17.4", | ||
"readline-sync": "^1.4.7" | ||
"chalk": "^5.0.1", | ||
"figlet": "^1.5.2", | ||
"fs-extra": "^10.1.0", | ||
"readline-sync": "^1.4.10" | ||
} | ||
} |
117
README.md
@@ -1,104 +0,31 @@ | ||
#A17 Generator | ||
# A17 Generator | ||
A17 Generator is used to quickly generate an [A17 Boilerplate](https://code.area17.com/a17/fe-boilerplate/tree/master). | ||
A17 Generator is used to quickly install A17 FE libraries. It can: | ||
## Usage | ||
* generate a `package.json` for you, | ||
* initialise Git, | ||
* set up a Webpack build process, | ||
* add helpful dot files, | ||
* set up linting, | ||
* set up a pre-commit hook, | ||
* generate a `frontend` folder structure, | ||
* generate a `README.md`, | ||
* install a pattern library, | ||
**Install A17 Generator globally** | ||
Plus, it has ASCII art. | ||
```shell | ||
$ npm install -g @area17/a17-generator | ||
``` | ||
## Usage | ||
**Go to the root of your project** | ||
Firstly, you'll want to `cd` into a project folder if it already exists, or if not: | ||
```shell | ||
$ cd project-root | ||
``` | ||
```shell | ||
$ mkdir project-name && cd project-name | ||
``` | ||
**Initialize the A17 Boilerplate** | ||
And then run `a17-generator`; | ||
```shell | ||
# @ ~/project-root | ||
$ a17-generator [project-name] | ||
``` | ||
```shell | ||
$ npx @area17/a17-generator | ||
``` | ||
Now you will have a `frontend` folder, a `package.json` file and all the node modules. | ||
A17 Boilerplate is installed too which can help you to run all your dev tasks through npm script, e.g.: | ||
```shell | ||
npm run build | ||
``` | ||
For more details, please refer to [A17 Boilerplate](https://code.area17.com/a17/fe-boilerplate/tree/master). | ||
## Change Log | ||
**0.1.16** | ||
Update to latest version of boilerplate and helpers | ||
**0.1.15** | ||
Update to latest version of boilerplate | ||
**0.1.14** | ||
Update to latest version of boilerplate | ||
**0.1.13** | ||
Update to latest version of boilerplate | ||
**0.1.12** | ||
Update to latest version of boilerplate | ||
**0.1.11** | ||
Update to latest version of boilerplate | ||
**0.1.10** | ||
Update to latest version of node, npm, boilerplate and helpers | ||
**0.1.9** | ||
Readme updates | ||
**0.1.8** | ||
Update to latest version of boilerplate and helpers | ||
**0.1.7** | ||
Update to latest version of boilerplate | ||
**0.1.6** | ||
Update to latest version of boilerplate | ||
**0.1.5** | ||
Update to latest version of boilerplate | ||
**0.1.4** | ||
Publish to npm | ||
**0.1.3** | ||
Make install information more clear | ||
**0.1.2** | ||
Add engines property to package.json | ||
**0.1.1** | ||
Updated default git packages link | ||
**0.1.0** | ||
The birth of A17 Generator | ||
You may be asked to install `a17-generator`. And then `a17-generator` will then ask you a series of questions and then begin installing and setting up as needed. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
55215
4
36
1112
1
Yes
32
7
6
+ Addedfiglet@^1.5.2
+ Addedchalk@5.4.1(transitive)
+ Addedfiglet@1.8.0(transitive)
+ Addedfs-extra@10.1.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addeduniversalify@2.0.1(transitive)
- Removedcross-spawn@^5.1.0
- Removedlodash@^4.17.4
- Removedansi-styles@3.2.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcross-spawn@5.1.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedfs-extra@4.0.3(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removeduniversalify@0.1.2(transitive)
- Removedwhich@1.3.1(transitive)
- Removedyallist@2.1.2(transitive)
Updatedchalk@^5.0.1
Updatedfs-extra@^10.1.0
Updatedreadline-sync@^1.4.10