Skip to content

Commit

Permalink
Merge pull request #3 from tpkemme/upgrade-local-v2
Browse files Browse the repository at this point in the history
Upgrade for Local v2
  • Loading branch information
tpkemme authored Jun 15, 2017
2 parents 415c21a + bedb8b4 commit 96abd16
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 235 deletions.
16 changes: 7 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ All notable changes to this project will be documented in this file. This projec
Generated by [auto-changelog](https://github.com/CookPete/auto-changelog)


## [v1.0.0](https://github.com/tpkemme/local-addon-plugins-themes/compare/v0.2.0...v1.0.0) - 2017-02-20

### Commits
* Merge branch 'master' of https://github.com/tpkemme/local-addon-plugins-themes [`a179234`](https://github.com/tpkemme/local-addon-plugins-themes/commit/a179234ccd563af07de6aa5888517c03a321f3f7)
## [v1.0.1](https://github.com/tpkemme/local-addon-plugins-themes/compare/1.0.0...v1.0.1) - 2017-06-15


## [v0.2.0](https://github.com/tpkemme/local-addon-plugins-themes/compare/v0.1.0...v0.2.0) - 2017-02-14
### Fixed Issues
* Updated addon to be compatible with Local v2.0 [\#2](https://github.com/tpkemme/local-addon-plugins-themes/issues/2)
([tpkemme](https://github.com/tpkemme))

### Commits
* finished plugin config and styles, need to finish theme config and styles [`62c71d1`](https://github.com/tpkemme/local-addon-plugins-themes/commit/62c71d1e2f5ef6f243b9cedf797f86028d4ef973)
* Update README.md [`8feeec8`](https://github.com/tpkemme/local-addon-plugins-themes/commit/8feeec8d885ac59465df1641847fc993041bd30e)


## v0.1.0 - 2017-02-14
## 1.0.0 - 2017-02-20

### Commits
* inital commit [`3d0bf4c`](https://github.com/tpkemme/local-addon-plugins-themes/commit/3d0bf4cfdf011bbaac9649398fe560f94affe788)
* Merge branch 'master' of https://github.com/tpkemme/local-addon-plugins-themes [`a179234`](https://github.com/tpkemme/local-addon-plugins-themes/commit/a179234ccd563af07de6aa5888517c03a321f3f7)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Description

Add this addon to Local By Flywheel to see the active and inactive plugins for each site. This addon currently lists active and inactive themes/plugins.
Add this addon to Local By Flywheel to see the active and inactive plugins for each site. This addon currently lists active and inactive themes/plugins. Now completely functional with Local by Flywheel v2.0. This addon will no longer work for Local versions less than 2.0

![local-addon-plugins-themes](https://cloud.githubusercontent.com/assets/3424234/23125040/90227d88-f735-11e6-84e7-f68313ef0e96.gif)

Expand All @@ -26,7 +26,7 @@ Add this addon to Local By Flywheel to see the active and inactive plugins for e
1. Clone this repo: `git clone git@github.com:JRGould/local-addon-plugins-themes.git local-addon-plugins-themes`
2. Run `npm install`
3. Run initial build: `npm run-script build`
4. Link into Local's `addon` directory: `ln -s "$(pwd)" ~/Library/Application Support/Local by Flywheel/addons`
4. Link into Local's `addon` directory: `ln -s "$(pwd)" ~/Library/Application\ Support/Local\ by\ Flywheel/addons`
5. Restart Local and activate addon from Settings > Addons

## Notes for Developers
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "local-addon-plugins-themes",
"productName": "Plugins And Themes Addon for Local by Flywheel",
"version": "1.0.0",
"version": "1.0.1",
"author": "Tyler Kemme",
"contributors": [
{
Expand Down Expand Up @@ -30,6 +30,6 @@
"run-when-changed": "^1.3.0"
},
"engines": {
"local-by-flywheel": "^1.1.0"
"local-by-flywheel": "^2.0.0"
}
}
213 changes: 107 additions & 106 deletions src/SitePluginsInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@ const path = require('path');

module.exports = function( context ) {

const Component = context.React.Component
const React = context.React
const $ = context.jQuery

return class SitePluginsInfo extends Component {
constructor( props ) {
super( props )
// init class vars
this.state = {
activeContent: null,
const Component = context.React.Component
const React = context.React
const $ = context.jQuery

return class SitePluginsInfo extends Component {
constructor( props ) {
super( props )
// init class vars
this.state = {
activeContent: null,
inactiveContent: null,
content: null
}
}

this.stylesheetPath = path.resolve(__dirname, '../style.css');
}
this.stylesheetPath = path.resolve(__dirname, '../style.css');
}

componentDidMount() {
// set up
componentDidMount() {
// set up
if ( 'running' === this.props.siteStatus ) {
this.getPluginList();
} else {
this.setState( { content: ( <p className="plugins-danger">Machine not running!</p> ) } )
this.setState( { activeContent: null} )
this.setState( { inactiveContent: null} )
}
}
}

componentWillUnmount() {
// tear down
}
componentWillUnmount() {
// tear down
}

getPluginList() {

Expand All @@ -54,126 +54,127 @@ module.exports = function( context ) {
<td className="plugins-table-info"> - </td>
</tr> } )

// get site object using siteID
let site = this.props.sites[ this.props.params.siteID ]

// construct command using bundled docker binary to execute 'wp plugin list' inside container for active plugins
let activeCommand = `${context.environment.dockerPath} exec ${site.container} wp plugin list --status=active --path=/app/public --format=csv --allow-root`

// execute command in docker env and run callback when it returns
childProcess.exec( activeCommand, { env: context.environment.dockerEnv }, (error, stdout, stderr) => {
// Display error message if there's an issue
if (error) {
this.setState( { activeContent:
<tr>
<td className="plugins-table-name">Error retrieving active plugin: <pre>{ stderr }</pre></td>
<td className="plugins-table-info"> - </td>
<td className="plugins-table-info"> - </td>
</tr> } )
} else {
// split list into array
let plugins = stdout.trim().split( "\n" )
plugins.splice(0, 1)

// Only create unordered list if there are plugins to list
if ( plugins.length && plugins[0].length > 1 ) {
this.setState( { activeContent: plugins.map( (item) =>
<tr>
<td className="plugins-table-name" key={ plugins.indexOf(item) }>{ item.trim().split( "," )[0] }</td>
<td className={ item.trim().split( "," )[2] + " plugins-table-info" } >{ item.trim().split( "," )[2] }</td>
<td className="plugins-table-info">{ item.trim().split( "," )[3] }</td>
</tr> ) } )
} else {
this.setState( { activeContent:
<tr>
<td className="plugins-table-name">No active plugins.</td>
<td className="plugins-table-info"> - </td>
<td className="plugins-table-info"> - </td>
</tr> } )
}
}
} );
// get site object using siteID
let site = this.props.sites[ this.props.params.siteID ]

// construct command using bundled docker binary to execute 'wp plugin list' inside container for active plugins
// IMPORTANT can't forget to escape any spaces in dockerPath!
let activeCommand = `${ context.environment.dockerPath.replace(/ /g, "\\ ") } exec ${site.container} wp plugin list --status=active --path=/app/public --format=csv --allow-root`

// execute command in docker env and run callback when it returns
childProcess.exec( activeCommand, { env: context.environment.dockerEnv }, (error, stdout, stderr) => {
// Display error message if there's an issue
if (error) {
this.setState( { activeContent:
<tr>
<td className="plugins-table-name">Error retrieving active plugin: <pre>{ error, stdout, stderr }</pre></td>
<td className="plugins-table-info"> - </td>
<td className="plugins-table-info"> - </td>
</tr> } )
}
else {
// split list into array
let plugins = stdout.trim().split( "\n" )
plugins.splice(0, 1)

// Only create unordered list if there are plugins to list
if ( plugins.length && plugins[0].length > 1 ) {
this.setState( { activeContent: plugins.map( (item) =>
<tr>
<td className="plugins-table-name" key={ plugins.indexOf(item) }>{ item.trim().split( "," )[0] }</td>
<td className={ item.trim().split( "," )[2] + " plugins-table-info" } >{ item.trim().split( "," )[2] }</td>
<td className="plugins-table-info">{ item.trim().split( "," )[3] }</td>
</tr> ) } )
}
else {
this.setState( { activeContent:
<tr>
<td className="plugins-table-name">No active plugins.</td>
<td className="plugins-table-info"> - </td>
<td className="plugins-table-info"> - </td>
</tr> } )
}
}
} );

// construct command using bundled docker binary to execute 'wp plugin list' inside container for inactive plugins
let inactiveCommand = `${context.environment.dockerPath} exec ${site.container} wp plugin list --status=inactive --path=/app/public --format=csv --allow-root`

// execute command in docker env and run callback when it returns
childProcess.exec( inactiveCommand, { env: context.environment.dockerEnv }, (error, stdout, stderr) => {
// Display error message if there's an issue
if (error) {
this.setState( { inactiveContent:
// IMPORTANT can't forget to escape any spaces in dockerPath!
let inactiveCommand = `${ context.environment.dockerPath.replace(/ /g, "\\ ") } exec ${site.container} wp plugin list --status=inactive --path=/app/public --format=csv --allow-root`

// execute command in docker env and run callback when it returns
childProcess.exec( inactiveCommand, { env: context.environment.dockerEnv }, (error, stdout, stderr) => {
// Display error message if there's an issue
if (error) {
this.setState( { inactiveContent:
<tr>
<td className="plugins-table-name">Error retrieving inactive plugin: <pre>{ stderr }</pre></td>
<td className="plugins-table-info"> - </td>
<td className="plugins-table-info"> - </td>
</tr> } )
} else {
// split list into array
let plugins = stdout.trim().split( "\n" )
plugins.splice(0, 1)

// Only create unordered list if there are plugins to list
if ( plugins.length && plugins[0].length > 1 ) {
this.setState( { inactiveContent: plugins.map( (item) =>
}
else {
// split list into array
let plugins = stdout.trim().split( "\n" )
plugins.splice(0, 1)

// Only create unordered list if there are plugins to list
if ( plugins.length && plugins[0].length > 1 ) {
this.setState( { inactiveContent: plugins.map( (item) =>
<tr>
<td className="plugins-table-name" key={ plugins.indexOf(item) }>{ item.trim().split( "," )[0] }</td>
<td className={ item.trim().split( "," )[2] + " plugins-table-info" } >{ item.trim().split( "," )[2] }</td>
<td className="plugins-table-info">{ item.trim().split( "," )[3] }</td>
</tr> ) } )
} else {
this.setState( { inactiveContent:
<tr>
<td className="plugins-table-name">No inactive plugins.</td>
<td className="plugins-table-info"> - </td>
<td className="plugins-table-info"> - </td>
</tr> } )
}
}
} );
} else {
this.setState( { inactiveContent:
<tr>
<td className="plugins-table-name">No inactive plugins.</td>
<td className="plugins-table-info"> - </td>
<td className="plugins-table-info"> - </td>
</tr> } )
}
}
} );

this.setState( { content: null} )

}

render() {
return (
render() {
return (
<div className="plugins-container">
<link rel="stylesheet" href={this.stylesheetPath}/>

{ this.state.content }

<h3 className="plugins-table-title">Active Plugins</h3>
<h3 className="plugins-table-title">Active Plugins</h3>
<table className="table-striped plugins-table">
<thead>
<tr className="plugin-table-head" >
<th className="plugins-table-name"><strong>Name</strong></th>
<th className="plugins-table-info"><strong>Update</strong></th>
<th className="plugins-table-info"><strong>Version</strong></th>
</tr>
<tr className="plugin-table-head" >
<th className="plugins-table-name"><strong>Name</strong></th>
<th className="plugins-table-info"><strong>Update</strong></th>
<th className="plugins-table-info"><strong>Version</strong></th>
</tr>
</thead>
<tbody>

{ this.state.activeContent }

{ this.state.activeContent }
</tbody>
</table>

<h3 className="plugins-table-title">Inactive Plugins</h3>
<h3 className="plugins-table-title">Inactive Plugins</h3>
<table className="table-striped plugins-table">
<thead>
<tr className="plugin-table-head" >
<th className="plugins-table-name"><strong>Name</strong></th>
<th className="plugins-table-info"><strong>Update</strong></th>
<th className="plugins-table-info"><strong>Version</strong></th>
</tr>
<tr className="plugin-table-head" >
<th className="plugins-table-name"><strong>Name</strong></th>
<th className="plugins-table-info"><strong>Update</strong></th>
<th className="plugins-table-info"><strong>Version</strong></th>
</tr>
</thead>
<tbody>
{ this.state.inactiveContent }
{ this.state.inactiveContent }
</tbody>
</table>
</div>
);
}
</div>
);
}

}
}
Loading

0 comments on commit 96abd16

Please sign in to comment.