Skip to content

Commit

Permalink
update sao
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Nov 6, 2018
1 parent 266b56b commit cc3ade4
Show file tree
Hide file tree
Showing 13 changed files with 1,015 additions and 495 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "template-template",
"name": "sao-generator",
"version": "0.9.1",
"description": "Scaffold out an SAO template",
"description": "Scaffold out an SAO generator",
"main": "index.js",
"repository": {
"url": "egoist/template-template",
"url": "saojs/sao-generator",
"type": "git"
},
"scripts": {
"test": "ava test/test*.js"
"test": "ava"
},
"author": "EGOIST <[email protected]>",
"license": "MIT",
Expand All @@ -17,6 +17,6 @@
},
"devDependencies": {
"ava": "^0.21.0",
"sao": "^0.20.8"
"sao": "^1.0.0"
}
}
42 changes: 0 additions & 42 deletions sao.js

This file was deleted.

58 changes: 58 additions & 0 deletions saofile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const superb = require('superb')

module.exports = {
prompts() {
return [
{
name: 'name',
message: 'What is the name of the new generator (must be sao-*)',
default: this.outFolder,
filter: val => val.toLowerCase()
},
{
name: 'description',
message: 'How would you descripe the new template',
default: `my ${superb()} SAO generator`
},
{
name: 'username',
message: 'What is your GitHub username',
default: this.gitUser.username || this.gitUser.name,
filter: val => val.toLowerCase(),
store: true
},
{
name: 'email',
message: 'What is your email?',
default: this.gitUser.email,
store: true
},
{
name: 'website',
message: 'The URL of your website',
default({ username }) {
return `github.com/${username}`
},
store: true
}
]
},
actions: [
{
type: 'add',
files: '**',
transformExclude: 'template/**'
},
{
type: 'move',
patterns: {
gitignore: '.gitignore'
}
}
],
async completed() {
this.gitInit()
await this.npmInstall()
this.showProjectTips()
}
}
2 changes: 1 addition & 1 deletion template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ npm i -g sao
### From npm

```bash
sao <%= name.replace('template-', '') %> my-project
sao <%= name.replace('sao-', '') %> my-project
```

### From git
Expand Down
6 changes: 3 additions & 3 deletions template/circle.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% const lockFile = _.pm === 'yarn' ? 'yarn.lock' : 'package-lock.json' -%>
<% const lockFile = context.npmClient === 'yarn' ? 'yarn.lock' : 'package-lock.json' -%>
version: 2
jobs:
build:
Expand All @@ -15,11 +15,11 @@ jobs:
key: dependency-cache-{{ checksum "<%= lockFile %>" }}
- run:
name: install dependences
command: <%= _.pm %> install
command: <%= context.npmClient %> install
- save_cache:
key: dependency-cache-{{ checksum "<%= lockFile %>" }}
paths:
- ./node_modules
- run:
name: test
command: <%= _.pm %> test
command: <%= context.npmClient %> test
4 changes: 2 additions & 2 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "<%= username %> <<%= email %>> (<%= website %>)",
"license": "MIT",
"files": [
"sao.js",
"saofile.js",
"template"
],
"scripts": {
Expand All @@ -20,6 +20,6 @@
},
"devDependencies": {
"ava": "^0.21.0",
"sao": "^0.22.1"
"sao": "^1.0.0"
}
}
37 changes: 0 additions & 37 deletions template/sao.js

This file was deleted.

56 changes: 56 additions & 0 deletions template/saofile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const superb = require('superb')

module.exports = {
prompts() {
return [
{
name: 'name',
message: 'What is the name of the new generator (must be sao-*)',
default: this.outFolder,
filter: val => val.toLowerCase()
},
{
name: 'description',
message: 'How would you descripe the new project',
default: `my ${superb()} project`
},
{
name: 'username',
message: 'What is your GitHub username',
default: this.gitUser.username || this.gitUser.name,
filter: val => val.toLowerCase(),
store: true
},
{
name: 'email'
message: 'What is your email?',
default: this.gitUser.email,
store: true
},
{
message: 'The URL of your website',
default({ username }) {
return `github.com/${username}`
},
store: true
}
]
},
actions: [
{
type: 'add',
files: '**'
},
{
type: 'move',
patterns: {
gitignore: '.gitignore'
}
}
],
async completed() {
this.gitInit()
await this.npmInstall()
this.showProjectTips()
}
}
4 changes: 2 additions & 2 deletions template/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import path from 'path'
import test from 'ava'
import sao from 'sao'

const template = path.join(__dirname, '..')
const generator = path.join(__dirname, '..')

test('defaults', async t => {
const stream = await sao.mockPrompt(template)
const stream = await sao.mock({ generator })

t.snapshot(stream.fileList, 'Generated files')
})
2 changes: 1 addition & 1 deletion test/snapshots/test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Generated by [AVA](https://ava.li).
'README.md',
'circle.yml',
'package.json',
'sao.js',
'saofile.js',
'template/.editorconfig',
'template/.gitattributes',
'template/LICENSE',
Expand Down
Binary file modified test/snapshots/test.js.snap
Binary file not shown.
4 changes: 2 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import path from 'path'
import test from 'ava'
import sao from 'sao'

const template = path.join(__dirname, '..')
const generator = path.join(__dirname, '..')

test('defaults', async t => {
const stream = await sao.mockPrompt(template)
const stream = await sao.mock({ generator })

t.snapshot(stream.fileList, 'Generated files')
})
Loading

0 comments on commit cc3ade4

Please sign in to comment.