-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ const action = (name) => { | |
} | ||
|
||
create(name); | ||
} | ||
}; | ||
|
||
program | ||
.arguments('<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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#! /usr/bin/env node | ||
/* eslint-disable no-console */ | ||
|
||
const program = require('commander'); | ||
const generate = require('../lib/generate'); | ||
|
||
program | ||
.arguments('<name>') | ||
.action(generate); | ||
|
||
program.on('--help', () => { | ||
console.log('Create a meteor project with react and redux configured.'); | ||
}); | ||
|
||
program.parse(process.argv); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const _ = require('lodash'); | ||
const path = require('path'); | ||
const rt = require('reacterminator'); | ||
const { ls } = require('shelljs'); | ||
|
||
function getMeteorRoot() { | ||
let currentPath = path.resolve('.'); | ||
do { | ||
const paths = ls('-A', currentPath); | ||
const isMeteorRoot = | ||
_.includes(paths, '.meteor') && | ||
_.includes(paths, 'package.json'); | ||
|
||
if (isMeteorRoot) { | ||
return currentPath; | ||
} | ||
|
||
currentPath = path.resolve(currentPath, '..'); | ||
} | ||
while (currentPath !== '/'); | ||
|
||
throw new Error('Ops, can not find your meteor project root directory.'); | ||
} | ||
|
||
module.exports = (rawPath) => rt.generate(rawPath, `${getMeteorRoot()}/client/imports`); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-env mocha */ | ||
const fs = require('fs'); | ||
const { assert } = require('chai'); | ||
const path = require('path'); | ||
const generate = require('../../lib/generate'); | ||
const { cd, rm, mkdir, touch } = require('shelljs'); | ||
|
||
describe('generate', () => { | ||
it('generate a component', () => { | ||
const examplesPath = path.resolve(__dirname, '../../examples'); | ||
cd(examplesPath); | ||
rm('-rf', 'example'); | ||
mkdir('-p', './example/.meteor/'); | ||
touch('./example/package.json'); | ||
cd('example'); | ||
|
||
generate('components/components/Signup'); | ||
|
||
assert(fs.statSync('client/imports/custom/index.js').isFile()); | ||
assert(fs.statSync('client/imports/custom/components/Signup.jsx').isFile()); | ||
}); | ||
}); |