Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
},
"dependencies": {
"autoprefixer": "^7.1.0",
"axios": "^0.16.2",
"babel-loader": "^7.0.0",
"babel-plugin-jsx-pragmatic": "^1.0.2",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
Expand Down
4 changes: 4 additions & 0 deletions src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export default asyncCommand({
desc: 'Create a production build in build/',

builder: {
cwd: {
description: 'A directory to use instead of $PWD.',
default: '.'
},
src: {
description: 'Entry file (index.js)',
default: 'src'
Expand Down
4 changes: 4 additions & 0 deletions src/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export default asyncCommand({
desc: 'Create a new application.',

builder: {
cwd: {
description: 'A directory to use instead of $PWD.',
default: '.'
},
name: {
description: 'The application\'s name'
},
Expand Down
29 changes: 29 additions & 0 deletions src/commands/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import axios from 'axios';
import { yellow, blue } from 'chalk';
import { error, info } from '../util';
import asyncCommand from '../lib/async-command';

const REPOS_URL = "https://api.github.com/users/preactjs-templates/repos";

export default asyncCommand({
command: 'list',

desc: 'List all official templates',

async handler() {
try {
let repos = await axios.get(REPOS_URL);

process.stdout.write('\n');
info('Available official templates: \n');

repos.data.map((repo => {
process.stdout.write(` ${yellow('★')} ${blue(repo.name)} - ${repo.description} \n`);
}));

process.stdout.write('\n');
} catch (err) {
error(err, 1);
}
}
});
4 changes: 4 additions & 0 deletions src/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export default asyncCommand({
desc: 'Start an HTTP2 static fileserver.',

builder: {
cwd: {
description: 'A directory to use instead of $PWD.',
default: '.'
},
dir: {
description: 'Directory root to serve static files from.',
default: 'build'
Expand Down
4 changes: 4 additions & 0 deletions src/commands/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export default asyncCommand({
desc: 'Start a development live-reload server.',

builder: {
cwd: {
description: 'A directory to use instead of $PWD.',
default: '.'
},
src: {
description: 'Entry file (index.js)',
default: 'src'
Expand Down
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import create from './commands/create';
import build from './commands/build';
import watch from './commands/watch';
import serve from './commands/serve';
import list from './commands/list';
import installHooks from './lib/output-hooks';
import pkg from '../package.json';
import logo from './lib/logo';
Expand All @@ -24,10 +25,11 @@ yargs
.command(build)
.command(watch)
.command(serve)
.option('cwd', {
description: 'A directory to use instead of $PWD.',
defaultDescription: '.'
})
.command(list)
// .option('cwd', {
// description: 'A directory to use instead of $PWD.',
// defaultDescription: '.'
// })
.usage(logo(`\n\npreact-cli ${pkg.version}`) + `\nFor help with a specific command, enter:\n preact help [command]`)
.help()
.alias('h', 'help')
Expand Down
19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,13 @@ [email protected]:
version "2.2.1"
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-2.2.1.tgz#d8fe7be13e2d80e407f96d3374ed64d5fb1c3e54"

axios@^0.16.2:
version "0.16.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.16.2.tgz#ba4f92f17167dfbab40983785454b9ac149c3c6d"
dependencies:
follow-redirects "^1.2.3"
is-buffer "^1.1.5"

[email protected]:
version "0.0.3"
resolved "https://registry.yarnpkg.com/babar/-/babar-0.0.3.tgz#2f394d4a5918f7e1ae9e5408e9a96f3f935ee1e2"
Expand Down Expand Up @@ -2043,6 +2050,12 @@ [email protected], debug@^2.1.1, debug@^2.2.0, debug@^2.6.3, debug@^2.6.6, debug@^2.6.
dependencies:
ms "2.0.0"

debug@^2.4.5:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
ms "2.0.0"

decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
Expand Down Expand Up @@ -2994,6 +3007,12 @@ flatten@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"

follow-redirects@^1.2.3:
version "1.2.4"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.2.4.tgz#355e8f4d16876b43f577b0d5ce2668b9723214ea"
dependencies:
debug "^2.4.5"

for-each@~0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4"
Expand Down