Skip to content

Commit

Permalink
Refactoring the folder names for isolate. Added underscore folders to…
Browse files Browse the repository at this point in the history
… exclution
  • Loading branch information
Eisi Sig committed Feb 19, 2016
1 parent d707c24 commit 69cf091
Show file tree
Hide file tree
Showing 35 changed files with 102 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.idea
node_modules
*.log
_lib
isolate-lib
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.idea
node_modules
_src
isolate-src
*.log
46 changes: 46 additions & 0 deletions demo/components/_Button/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict';

import React, { PropTypes } from 'react';

import './Button3.less';

/**
* # Button
*/
export default class Button extends React.Component {

static propTypes = {
/**
* This is the main value
*/
value: PropTypes.string.isRequired,
/**
* Shape
*/
optionalShape: PropTypes.shape({
onLoad: PropTypes.func,
onSliceClick: PropTypes.func,
onSliceHover: PropTypes.func
}),
optionalObjectOf: PropTypes.objectOf(PropTypes.number),
optionalArrayOf: PropTypes.arrayOf(PropTypes.number),
optionalUnion: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.instanceOf(Date)
]),
optionalEnum: PropTypes.oneOf(['News', 'Photos']),
optionalMessage: PropTypes.instanceOf(Date)
};

static defaultProps = {
value: null
};

render () {
const { value } = this.props;
return (
<button className="Button">{ value }</button>
);
}
}
3 changes: 3 additions & 0 deletions demo/components/_Button/Button.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.Button {
border: 1px solid red !important;
}
File renamed without changes.
2 changes: 1 addition & 1 deletion _src/_components/App.js → isolate-src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import PureComponent from 'react-pure-render/component';
import SideBar from './SideBar';

import styles from '../../_styles/components/App.less';
import styles from '../../isolate-styles/components/App.less';

/**
* # App
Expand Down
4 changes: 2 additions & 2 deletions _src/_components/Docs.js → isolate-src/components/Docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { AllHtmlEntities } from 'html-entities';

const entities = new AllHtmlEntities();

import ui from '../../_styles/ui.less';
import styles from '../../_styles/components/Docs.less';
import ui from '../../isolate-styles/ui.less';
import styles from '../../isolate-styles/components/Docs.less';

marked.setOptions({
renderer: new marked.Renderer(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import PureComponent from 'react-pure-render/component';
import PropList from './PropList';
import Docs from './Docs';

import ui from '../../_styles/ui.less';
import styles from '../../_styles/components/Documentation.less';
import ui from '../../isolate-styles/ui.less';
import styles from '../../isolate-styles/components/Documentation.less';

/**
* # Documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'codemirror/addon/lint/lint.css';
import 'codemirror/addon/lint/json-lint';


import styles from '../../_styles/components/Editor.less';
import styles from '../../isolate-styles/components/Editor.less';

/**
* Editor
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CodeMirror from 'codemirror';
import PureComponent from 'react-pure-render/component';
import 'codemirror/mode/javascript/javascript';

//import styles from '../_styles/components/Markup.less';
//import styles from '../isolate-styles/components/Markup.less';

/**
* Markup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import _ from 'lodash';
import ReactDOM from 'react-dom';
import React, {PropTypes} from 'react';
import PureComponent from 'react-pure-render/component';
import {renderComponentMarkup} from '../../_lib/utils';
import {renderComponentMarkup} from '../utils';

import Editor from './Editor';
import Markup from './Markup';

import ui from '../../_styles/ui.less';
import styles from '../../_styles/components/Preview.less';
import ui from '../../isolate-styles/ui.less';
import styles from '../../isolate-styles/components/Preview.less';

/**
* # PreviewPanel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import React, {PropTypes} from 'react';
import orderBy from 'lodash/orderBy';
import PureComponent from 'react-pure-render/component';
import styles from '../../_styles/components/PropList.less';
import ui from '../../_styles/ui.less';
import styles from '../../isolate-styles/components/PropList.less';
import ui from '../../isolate-styles/ui.less';

/**
* # PropList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import _ from 'lodash';
import { Link } from 'react-router';
import PureComponent from 'react-pure-render/component';

import ui from '../../_styles/ui.less';
import styles from '../../_styles/components/SideBar.less';
import ui from '../../isolate-styles/ui.less';
import styles from '../../isolate-styles/components/SideBar.less';

/**
* SideBar
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions _src/entry.js → isolate-src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {createHistory, useBasename} from 'history';
import {Router, Route, IndexRoute} from 'react-router';
import {removeExtension} from './utils';

import App from './_components/App';
import Preview from './_components/Preview';
import Documentation from './_components/Documentation';
import App from './components/App';
import Preview from './components/Preview';
import Documentation from './components/Documentation';

Perf.start();

Expand All @@ -22,7 +22,7 @@ Perf.start();
* @type {*}
*/
const componentsContext = require.context('COMPONENTS_PATH', true, /^\.\/.*\.js$/);
const componentsMap = componentsContext.keys().reduce(( results, filePath ) => {
const componentsMap = componentsContext.keys().reduce((results, filePath) => {

const fileArr = removeExtension(filePath).split('/').splice(1);
let Component = componentsContext(filePath);
Expand Down Expand Up @@ -62,7 +62,7 @@ const componentsMap = componentsContext.keys().reduce(( results, filePath ) => {
* @type {*}
*/
const docsContext = require.context('COMPONENTS_PATH', true, /^\.\/.*\.md$/);
const docsMap = docsContext.keys().reduce(( results, filePath ) => {
const docsMap = docsContext.keys().reduce((results, filePath) => {

const fileArr = removeExtension(filePath, '.md').split('/').splice(1);
const mainComponentName = fileArr[0];
Expand Down Expand Up @@ -93,7 +93,7 @@ const docsMap = docsContext.keys().reduce(( results, filePath ) => {
* @type {*}
*/
const fixturesContext = require.context('FIXTURES_PATH', true, /^\.\/.*\.js$/);
const fixturesMap = fixturesContext.keys().reduce(( results, filePath ) => {
const fixturesMap = fixturesContext.keys().reduce((results, filePath) => {
let props = fixturesContext(filePath);

if ( 'default' in props ) props = props.default;
Expand All @@ -119,8 +119,8 @@ const fixturesMap = fixturesContext.keys().reduce(( results, filePath ) => {
});
}, {});

const mergeAll = ( componentsMap, fixturesMap, docsMap ) => merge(componentsMap, fixturesMap, docsMap);
const clean = ( data ) => omit(data, ( item ) => !item.name);
const mergeAll = (componentsMap, fixturesMap, docsMap) => merge(componentsMap, fixturesMap, docsMap);
const clean = (data) => omit(data, (item) => !item.name);
const prepareData = flowRight(clean, mergeAll);

/**
Expand All @@ -129,7 +129,7 @@ const prepareData = flowRight(clean, mergeAll);
const appData = prepareData(componentsMap, fixturesMap, docsMap);

console.groupCollapsed('Components total:', Object.keys(appData).length);
Object.keys(appData).forEach(( key ) => {
Object.keys(appData).forEach((key) => {
console.groupCollapsed(key, (appData[key].components) ? Object.keys(appData[key].components).length : '');
console.log(appData[key]);
console.groupEnd();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"main": "index.js",
"scripts": {
"dev": "concurrent \"npm run watch\" \"node .bin/start\" ",
"build": "babel _src --out-dir _lib --presets es2015,stage-0,react --plugins jsx-control-statements --no-babelrc",
"watch": "babel _src --out-dir _lib --presets es2015,stage-0,react --plugins jsx-control-statements --no-babelrc --watch",
"build": "babel isolate-src --out-dir isolate-lib --presets es2015,stage-0,react --plugins jsx-control-statements --no-babelrc",
"watch": "babel isolate-src --out-dir isolate-lib --presets es2015,stage-0,react --plugins jsx-control-statements --no-babelrc --watch",
"demo": "./.bin/start.js --componentsPath=demo/components --fixturesPath=demo/fixtures",
"styles": "./.bin/start.js --componentsPath=demo/components --fixturesPath=demo/fixtures --autoImportLess",
"lint": "eslint _components _lib",
"lint": "eslint _components isolate-lib",
"prepublish": "in-publish && npm run build",
"test": "echo \"Run tests\" && exit 0"
},
Expand Down
43 changes: 25 additions & 18 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ var cwd = process.cwd();

var isolateConfig = require('./config')(argv);

var resolvePath = function ( userPath ) {
var resolvePath = function (userPath) {
return cwd + '/' + userPath;
};

var ignore = new webpack.IgnorePlugin(/\/_.+\//);

var babelQuery = {
babelrc: false,
presets: ['es2015', 'stage-0', 'react'],
Expand All @@ -20,20 +22,15 @@ var babelQuery = {
'transform-decorators-legacy'
],
env: {},
//only: [
// "demo/**/*.js",
// "src/**/*.js",
// "fixtures/**/*.js",
// "*/ui/lib/index.js",
// "*/ui/lib/**/*.{js,less}"
//],
only: [
'demo/**/*.js',
'isolate-src/**/*.js',
'src/**/*.js',
'fixtures/**/*.js',
'node_modules\/@cosmic'
],
ignore: [
"**/_*/**",
"src/node-app/**/nod_modules",
"node_modules"
]
Expand Down Expand Up @@ -65,18 +62,18 @@ if ( isolateConfig.autoImportStyle ) {
jsLoader = 'component-css?ext=' + isolateConfig.autoImportStyleExt + '!' + jsLoader;
}

module.exports = function ( customConfig ) {
module.exports = function (customConfig) {
var defaultConfig = {
context: __dirname,
debug: true,
cache: true,
devtool: 'eval',
entry: [
path.resolve(__dirname, '_vendor', 'highlight.default.min.css'),
path.resolve(__dirname, '_vendor', 'highlight.github.min.css'),
path.resolve(__dirname, 'isolate-vendor', 'highlight.default.min.css'),
path.resolve(__dirname, 'isolate-vendor', 'highlight.github.min.css'),
//path.resolve(__dirname, '_vendor', 'jsonlint-1.6.0.min.js'),
path.resolve(__dirname, '_lib', 'entry.js'),
path.resolve(__dirname, '_styles', 'global.less')
path.resolve(__dirname, 'isolate-lib', 'entry.js'),
path.resolve(__dirname, 'isolate-styles', 'global.less')
].concat(argv.static ? [] : 'webpack-hot-middleware/client'),
output: {
path: path.resolve(cwd, isolateConfig.outputPath),
Expand Down Expand Up @@ -127,7 +124,16 @@ module.exports = function ( customConfig ) {
},
{
test: /\.js$/,
loader: jsLoader
loader: jsLoader,
include: [
'isolate-src',
'src',
'demo',
'fixtures',
],
exclude: [
/_.+?\//
]
},
{
test: /\.json$/,
Expand All @@ -151,26 +157,27 @@ module.exports = function ( customConfig ) {
{
test: /\.less$/,
loader: 'style!css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!less',
include: /_styles/
include: /isolate-styles/
},
{
test: /\.css$/,
loader: 'style!css',
exclude: /_styles/
exclude: /isolate-styles/
},
{
test: /\.less$/,
loader: 'style!css!less',
exclude: /_styles/
exclude: /isolate-styles/
}
]
},
plugins: [
ignore,
new webpack.NoErrorsPlugin()
].concat(argv.static ? [] : new webpack.HotModuleReplacementPlugin())
};

var webpackConfig = _.merge(defaultConfig, customConfig.webpackConfig, ( a, b ) => {
var webpackConfig = _.merge(defaultConfig, customConfig.webpackConfig, (a, b) => {
if ( _.isArray(a) ) return a.concat(b);
});

Expand Down

0 comments on commit 69cf091

Please sign in to comment.