-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,819 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v18.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,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 | ||
|
||
**Install A17 Generator globally** | ||
|
||
```shell | ||
$ npm install -g @area17/a17-generator | ||
``` | ||
|
||
**Go to the root of your project** | ||
|
||
```shell | ||
$ cd project-root | ||
``` | ||
|
||
**Initialize the A17 Boilerplate** | ||
|
||
```shell | ||
# @ ~/project-root | ||
$ a17-generator [project-name] | ||
``` | ||
|
||
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 | ||
* 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, | ||
|
||
**0.1.12** | ||
Plus, it has ASCII art. | ||
|
||
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** | ||
## Usage | ||
|
||
Add engines property to package.json | ||
Firstly, you'll want to `cd` into a project folder if it already exists, or if not: | ||
|
||
**0.1.1** | ||
```shell | ||
$ mkdir project-name && cd project-name | ||
``` | ||
|
||
Updated default git packages link | ||
And then run `a17-generator`; | ||
|
||
**0.1.0** | ||
```shell | ||
$ npx @area17/a17-generator | ||
``` | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,68 @@ | ||
#!/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]; | ||
|
||
|
||
// Main install process | ||
console.log(chalk.green('Start to install')); | ||
|
||
console.log(`Creating '${appName}' at ${process.cwd()} \n`); | ||
|
||
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 | ||
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'; | ||
|
||
// 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')); | ||
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.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 | ||
`); | ||
|
||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { manageBehaviors } from '@area17/a17-behaviors'; | ||
import * as Behaviors from './behaviors'; // Critical behaviors | ||
|
||
window.A17 = window.A17 || {}; // currently namespaced name *is* important | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
// expose manageBehaviors | ||
window.A17.behaviors = manageBehaviors; | ||
// init behaviors! | ||
window.A17.behaviors.init(Behaviors, { | ||
breakpoints: ['sm', 'md', 'lg', 'xl'] // tell this app what your breakpoint names are, in size order, manageBehaviors will read a CSS variable and compare for media scoped behaviors, default is ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'] | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as myBehavior } from './myBehavior'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { createBehavior } from '@area17/a17-behaviors'; | ||
|
||
const myBehavior = createBehavior('myBehavior', | ||
{ | ||
alert(val) { | ||
window.alert('Hello world!'); | ||
} | ||
}, | ||
{ | ||
init() { | ||
this.$node.addEventListener('click', this.alert); | ||
}, | ||
destroy() { | ||
this.$node.removeEventListener('click', this.alert); | ||
} | ||
} | ||
); | ||
|
||
export default myBehavior; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Node | ||
/vendor/ | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
# MacOS System | ||
.DS_Store | ||
|
||
# Laravel 4 specific | ||
bootstrap/compiled.php | ||
app/storage/ | ||
|
||
# Laravel 5 & Lumen specific | ||
public/storage | ||
public/hot | ||
|
||
# Laravel 5 & Lumen specific with changed public path | ||
public_html/storage | ||
public_html/hot | ||
|
||
# SCSS | ||
.sass-cache/ | ||
*.css.map | ||
*.sass.map | ||
*.scss.map | ||
|
||
storage/*.key | ||
.env | ||
Homestead.yaml | ||
Homestead.json | ||
/.vagrant | ||
.phpunit.result.cache | ||
/public | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
node_modules | ||
dist | ||
public | ||
storage | ||
vendor | ||
.vagrant | ||
.phpunit.result.cache | ||
.sass-cache | ||
*.css.map | ||
*.sass.map | ||
*.scss.map | ||
.DS_Store |
Oops, something went wrong.