From 6539f3a1b65ea3f843b6a5345b2a5ec393faec7e Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Sat, 18 May 2019 14:01:16 +0430 Subject: [PATCH] feat: upgrade to sao@1 (fixes #64) --- README.md | 2 +- sao.js | 38 -------------------------------------- saofile.js | 41 +++++++++++++++++++++++++++++++++++++++++ template/README.md | 14 +++++++------- 4 files changed, 49 insertions(+), 46 deletions(-) delete mode 100644 sao.js create mode 100644 saofile.js diff --git a/README.md b/README.md index 5dfbf08..060a0b1 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ to rapidly create efficient and feature-reach [PWA](https://developers.google.co Use the command below to create a new app using starter template: ```bash -> npx sao nuxt-community/nuxt7 nuxt7-app +> npx sao@1 nuxt-community/nuxt7 nuxt7-app ``` ## ▶️ Examples diff --git a/sao.js b/sao.js deleted file mode 100644 index b2a8b52..0000000 --- a/sao.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = { - prompts: { - name: { - message: 'Project name', - default: ':folderName:' - }, - description: { - message: 'Project description', - default: `My PWA App` - } - }, - - move: { - 'gitignore': '.gitignore' - }, - - post ({ yarnInstall, gitInit, chalk, pm, isNewFolder, folderName }) { - gitInit() - - yarnInstall() - - const cd = () => { - if (isNewFolder) { - console.log(` ${chalk.cyan('cd')} ${folderName}`) - } - } - - console.log() - console.log(chalk.bold(` To get started:\n`)) - cd() - console.log(` ${chalk.cyan(pm)} run dev\n`) - console.log(chalk.bold(` To build for production:\n`)) - cd() - console.log(` ${chalk.cyan(pm)} run build`) - console.log(` ${chalk.cyan(pm)} start`) - console.log() - } -} diff --git a/saofile.js b/saofile.js new file mode 100644 index 0000000..05071f8 --- /dev/null +++ b/saofile.js @@ -0,0 +1,41 @@ +module.exports = { + prompts () { + return [ + { + name: 'name', + message: 'Project name', + default: this.outFolder + }, + { + name: 'description', + message: 'Project description', + default: `` + } + ] + }, + + templateData () { + return { + name: this.answers.name, + description: this.answers.description + } + }, + + actions: [ + { + type: 'add', + files: '**' + }, + { type: 'move', + patterns: { + gitignore: '.gitignore' + } + } + ], + + async completed () { + this.gitInit() + await this.npmInstall() + this.showProjectTips() + } +} diff --git a/template/README.md b/template/README.md index e1ddcc7..96e53f8 100644 --- a/template/README.md +++ b/template/README.md @@ -2,21 +2,21 @@ > <%= description %> -## Build Setup +## Development ``` bash # Install dependencies -$ <%= _.pm %> install +<% if (context.npmClient === 'yarn') { %>yarn add<% } else { %>npm i<% } %> <%= name %> -# Serve with hot reload at localhost:3000 -$ <%= _.pm %> run dev +# Serve with hot-reload at localhost:3000 +<%= context.npmClient %> run dev # Build for production and launch server -$ <%= _.pm %> run build -$ <%= _.pm %> start +<%= context.npmClient %> run build +<%= context.npmClient %> start # Generate static project -$ <%= _.pm %> run generate +<%= context.npmClient %> run generate ``` For detailed explanation on how things work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js).