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
prompting() { | |
// Have Yeoman greet the user. | |
this.log(yosay(`Welcome from ${chalk.yellow('KIAN')} development team.`)); | |
const prompts = [ | |
{ | |
type: 'input', | |
name: 'name', | |
message: 'project name?' | |
}, |
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
{ | |
"projectName": "some-name", | |
"coolFeatures": true | |
} |
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
{ | |
"projectName": "<%= name %>", | |
"coolFeatures": <%= cool %> | |
} |
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
writing() { | |
this.fs.copyTpl(this.templatePath('_data.json'), this.destinationPath('/data.json'), { | |
name: this.props.name, | |
cool: this.props.cool | |
}); | |
} |
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
constructor(args, opts) { | |
super(args, opts); | |
// Define argument. | |
this.argument('arg1', { type: String, required: false }); | |
// Define options | |
this.option('coffee', { type: String, required: false }); | |
// And you can then access it later; e.g. | |
// this.log(this.options.arg1); |
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
'use strict'; | |
const Generator = require('yeoman-generator'); | |
const chalk = require('chalk'); | |
const yosay = require('yosay'); | |
module.exports = class extends Generator { | |
// Note: arguments and options should be defined in the constructor. | |
constructor(args, opts) { | |
super(args, opts); |
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
// npm install react-pwa-toolkit | |
import React from "react"; | |
import Device, { useNetwork, usePwa, useVisibility, useInstallPrompt } from "react-pwa-toolkit"; |
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
useEffect(() => { | |
console.log(Device()); | |
}) | |
// { | |
// "browser": { | |
// "name": "Safari", | |
// "version": "11.0" | |
// }, | |
// "os": { |
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
const isPwa = usePwa(); // true/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
const isVisible = useVisibility(); // true/false |