{"version":3,"file":"index.js","sources":["../src/element.js"],"sourcesContent":["'use strict';\r\nimport Generator from 'yeoman-generator';\r\nimport chalk from 'chalk';\r\nimport yosay from 'yosay';\r\nimport utils from 'backed-utils';\r\nimport { basename } from 'path';\r\nimport os from 'os';\r\nconst platform = os.platform();\r\n\r\nexport default class extends Generator {\r\n  constructor(args, opts) {\r\n    super(args, opts);\r\n\r\n    // This method adds support for a `--default` flag\r\n    this.option('default');\r\n    this.argument('name', {type: 'string', required: false});\r\n    this.props = {};\r\n  }\r\n\r\n  prompting() {\r\n    var prompts = [{\r\n      type: 'input',\r\n      name: 'name',\r\n      message: 'Whats the name for your component?',\r\n      default: basename(process.cwd())\r\n    }, {\r\n      type: 'input',\r\n      name: 'version',\r\n      message: 'Version',\r\n      default: '0.0.0'\r\n    }, {\r\n      type: 'input',\r\n      name: 'description',\r\n      message: 'Description',\r\n      default: ''\r\n    }, {\r\n      type: 'input',\r\n      name: 'homepage',\r\n      message: 'Project homepage url',\r\n      default: ''\r\n    }, {\r\n      type: 'input',\r\n      store: true,\r\n      name: 'authorName',\r\n      message: 'Author\\'s Name',\r\n      default: this.user.git.name()\r\n    }, {\r\n      type: 'input',\r\n      store: true,\r\n      name: 'authorEmail',\r\n      message: 'Author\\'s Email',\r\n      default: this.user.git.email()\r\n    }, {\r\n      type: 'input',\r\n      store: true,\r\n      name: 'authorUrl',\r\n      message: 'Author\\'s Homepage',\r\n      default: ''\r\n    }, {\r\n      type: 'confirm',\r\n      store: true,\r\n      name: 'license',\r\n      message: 'Include license?',\r\n      default: true\r\n    }];\r\n    return this.prompt(prompts).then(props => {\r\n      this.props = props;\r\n    });\r\n  }\r\n\r\n  configuring() {\r\n    this.composeWith(require.resolve('generator-node/generators/git'), {\r\n      name: this.props.name,\r\n      githubAccount: this.props.authorEmail\r\n    });\r\n\r\n    if (this.props.license) {\r\n      this.composeWith(require.resolve('generator-license/app'), {\r\n        name: this.props.authorName,\r\n        email: this.props.authorEmail,\r\n        website: this.props.authorUrl\r\n      });\r\n    }\r\n  }\r\n\r\n  writing() {\r\n    const moduleName = utils.toJsProp(this.props.name);\r\n\r\n    this.fs.copy(\r\n      this.templatePath('.*'),\r\n      this.destinationPath('./')\r\n    );\r\n\r\n    this.fs.copyTpl(\r\n      this.templatePath('package.json'),\r\n      this.destinationPath('package.json'),\r\n      {\r\n        name: this.props.name,\r\n        version: this.props.version,\r\n        authorName: this.props.authorName,\r\n        authorEmail: this.props.authorEmail,\r\n        authorUrl: this.props.authorUrl\r\n      }\r\n    );\r\n\r\n    this.fs.copyTpl(\r\n      this.templatePath('bower.json'),\r\n      this.destinationPath('bower.json'),\r\n      {\r\n        name: this.props.name,\r\n        version: this.props.version,\r\n        authorName: this.props.authorName,\r\n        authorEmail: this.props.authorEmail,\r\n        authorUrl: this.props.authorUrl\r\n      }\r\n    );\r\n\r\n    this.fs.copyTpl(\r\n      this.templatePath('backed-element.html'),\r\n      this.destinationPath(`src/${this.props.name}.js`),\r\n      {\r\n        className: moduleName.charAt(0).toUpperCase() + moduleName.slice(1),\r\n        name: this.props.name\r\n      }\r\n    );\r\n\r\n    this.fs.copyTpl(\r\n      this.templatePath('demo.html'),\r\n      this.destinationPath('demo/index.html'),\r\n      {\r\n        name: this.props.name\r\n      }\r\n    );\r\n  }\r\n\r\n  install() {\r\n    try {\r\n      console.log(chalk.yellow('backed --version'))\r\n      this.spawnCommandSync('backed', ['version']);\r\n    } catch (e) {\r\n      if (platform === 'win32') {\r\n        this.spawnCommandSync('yarn', ['global', 'add', 'backed-cli']);\r\n      } else {\r\n        this.spawnCommandSync('sudo', ['yarn', 'global', 'add', 'backed-cli']);\r\n      }\r\n    }\r\n    this.log('Swiping things up');\r\n    this.spawnCommand('rm', ['-rf', 'node_modules']);\r\n\r\n    this.installDependencies({\r\n      bower: true,\r\n      npm: false,\r\n      yarn: false\r\n    });\r\n  }\r\n}\r\n"],"names":["platform","os","args","opts","option","argument","type","required","props","prompts","basename","process","cwd","user","git","name","email","prompt","then","composeWith","require","resolve","authorEmail","license","authorName","authorUrl","moduleName","utils","toJsProp","fs","copy","templatePath","destinationPath","copyTpl","version","charAt","toUpperCase","slice","log","chalk","yellow","spawnCommandSync","e","spawnCommand","installDependencies","Generator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAMA,WAAWC,GAAGD,QAAH,EAAjB;;;kBAGcE,IAAZ,EAAkBC,IAAlB,EAAwB;;+GAChBD,IADgB,EACVC,IADU;UAIjBC,MAAL,CAAY,SAAZ;UACKC,QAAL,CAAc,MAAd,EAAsB,EAACC,MAAM,QAAP,EAAiBC,UAAU,KAA3B,EAAtB;UACKC,KAAL,GAAa,EAAb;;;;;gCAGU;;UACNC,UAAU,CAAC;cACP,OADO;cAEP,MAFO;iBAGJ,oCAHI;iBAIJC,cAASC,QAAQC,GAAR,EAAT;OAJG,EAKX;cACK,OADL;cAEK,SAFL;iBAGQ,SAHR;iBAIQ;OATG,EAUX;cACK,OADL;cAEK,aAFL;iBAGQ,aAHR;iBAIQ;OAdG,EAeX;cACK,OADL;cAEK,UAFL;iBAGQ,sBAHR;iBAIQ;OAnBG,EAoBX;cACK,OADL;eAEM,IAFN;cAGK,YAHL;iBAIQ,gBAJR;iBAKQ,KAAKC,IAAL,CAAUC,GAAV,CAAcC,IAAd;OAzBG,EA0BX;cACK,OADL;eAEM,IAFN;cAGK,aAHL;iBAIQ,iBAJR;iBAKQ,KAAKF,IAAL,CAAUC,GAAV,CAAcE,KAAd;OA/BG,EAgCX;cACK,OADL;eAEM,IAFN;cAGK,WAHL;iBAIQ,oBAJR;iBAKQ;OArCG,EAsCX;cACK,SADL;eAEM,IAFN;cAGK,SAHL;iBAIQ,kBAJR;iBAKQ;OA3CG,CAAd;aA6CO,KAAKC,MAAL,CAAYR,OAAZ,EAAqBS,IAArB,CAA0B,iBAAS;eACnCV,KAAL,GAAaA,KAAb;OADK,CAAP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