diff --git a/CHANGELOG.md b/CHANGELOG.md index f603d0f..8eb0cca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.md b/README.md index 04aa017..c10c18b 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 diff --git a/package.json b/package.json index d8738c8..27ffcef 100644 --- a/package.json +++ b/package.json @@ -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": [ { @@ -30,6 +30,6 @@ "run-when-changed": "^1.3.0" }, "engines": { - "local-by-flywheel": "^1.1.0" + "local-by-flywheel": "^2.0.0" } } diff --git a/src/SitePluginsInfo.js b/src/SitePluginsInfo.js index ada7365..1b5b763 100644 --- a/src/SitePluginsInfo.js +++ b/src/SitePluginsInfo.js @@ -4,25 +4,25 @@ 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 { @@ -30,11 +30,11 @@ module.exports = function( context ) { this.setState( { activeContent: null} ) this.setState( { inactiveContent: null} ) } - } + } - componentWillUnmount() { - // tear down - } + componentWillUnmount() { + // tear down + } getPluginList() { @@ -54,126 +54,127 @@ module.exports = function( context ) { - } ) - // 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: - - Error retrieving active plugin:
{ stderr }
- - - - - } ) - } 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) => - - { item.trim().split( "," )[0] } - { item.trim().split( "," )[2] } - { item.trim().split( "," )[3] } - ) } ) - } else { - this.setState( { activeContent: - - No active plugins. - - - - - } ) - } - } - } ); + // 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: + + Error retrieving active plugin:
{ error, stdout, stderr }
+ - + - + } ) + } + 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) => + + { item.trim().split( "," )[0] } + { item.trim().split( "," )[2] } + { item.trim().split( "," )[3] } + ) } ) + } + else { + this.setState( { activeContent: + + No active plugins. + - + - + } ) + } + } + } ); // 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: Error retrieving inactive plugin:
{ stderr }
- - } ) - } 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) => { item.trim().split( "," )[0] } { item.trim().split( "," )[2] } { item.trim().split( "," )[3] } ) } ) - } else { - this.setState( { inactiveContent: - - No inactive plugins. - - - - - } ) - } - } - } ); + } else { + this.setState( { inactiveContent: + + No inactive plugins. + - + - + } ) + } + } + } ); this.setState( { content: null} ) - } - render() { - return ( + render() { + return (
{ this.state.content } -

Active Plugins

+

Active Plugins

- - - - - + + + + + - - { this.state.activeContent } - + { this.state.activeContent }
NameUpdateVersion
NameUpdateVersion
-

Inactive Plugins

+

Inactive Plugins

- - - - - + + + + + - { this.state.inactiveContent } + { this.state.inactiveContent }
NameUpdateVersion
NameUpdateVersion
-
- ); - } + + ); } - + } } diff --git a/src/SiteThemesInfo.js b/src/SiteThemesInfo.js index cdd79e9..8d6a677 100644 --- a/src/SiteThemesInfo.js +++ b/src/SiteThemesInfo.js @@ -4,25 +4,25 @@ const path = require('path'); module.exports = function( context ) { - const Component = context.React.Component - const React = context.React - const $ = context.jQuery - - return class SiteThemesInfo 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 SiteThemesInfo extends Component { + constructor( props ) { + super( props ) + // init class vars + this.state = { + activeContent: null, inactiveContent: null, content: null } this.stylesheetPath = path.resolve(__dirname, '../style.css'); - } + } - componentDidMount() { - // set up + componentDidMount() { + // set up if ( 'running' === this.props.siteStatus ) { this.getThemeList(); } else { @@ -30,11 +30,11 @@ module.exports = function( context ) { this.setState( { activeContent: null} ) this.setState( { inactiveContent: null} ) } - } + } - componentWillUnmount() { - // tear down - } + componentWillUnmount() { + // tear down + } getThemeList() { @@ -54,126 +54,126 @@ module.exports = function( context ) { - } ) - // get site object using siteID - let site = this.props.sites[ this.props.params.siteID ] - - // construct command using bundled docker binary to execute 'wp theme list' inside container for active themes - let activeCommand = `${context.environment.dockerPath} exec ${site.container} wp theme 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: - - Error retrieving active theme:
{ stderr }
- - - - - } ) - } else { - // split list into array - let themes = stdout.trim().split( "\n" ) - themes.splice(0, 1) - - // Only create unordered list if there are themes to list - if ( themes.length && themes[0].length > 1 ) { - this.setState( { activeContent: themes.map( (item) => - - { item.trim().split( "," )[0] } - { item.trim().split( "," )[2] } - { item.trim().split( "," )[3] } - ) } ) - } else { - this.setState( { activeContent: - - No active themes. - - - - - } ) - } - } - } ); + // get site object using siteID + let site = this.props.sites[ this.props.params.siteID ] + + // construct command using bundled docker binary to execute 'wp theme list' inside container for active themes + // IMPORTANT can't forget to escape any spaces in dockerPath! + let activeCommand = `${ context.environment.dockerPath.replace(/ /g, "\\ ") } exec ${site.container} wp theme 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: + + Error retrieving active theme:
{ stderr }
+ - + - + } ) + } else { + // split list into array + let themes = stdout.trim().split( "\n" ) + themes.splice(0, 1) + + // Only create unordered list if there are themes to list + if ( themes.length && themes[0].length > 1 ) { + this.setState( { activeContent: themes.map( (item) => + + { item.trim().split( "," )[0] } + { item.trim().split( "," )[2] } + { item.trim().split( "," )[3] } + ) } ) + } else { + this.setState( { activeContent: + + No active themes. + - + - + } ) + } + } + } ); // construct command using bundled docker binary to execute 'wp theme list' inside container for inactive themes - let inactiveCommand = `${context.environment.dockerPath} exec ${site.container} wp theme 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: - - Error retrieving inactive theme:
{ stderr }
- - - - - } ) - } else { - // split list into array - let themes = stdout.trim().split( "\n" ) - themes.splice(0, 1) - - // Only create unordered list if there are themes to list - if ( themes.length && themes[0].length > 1 ) { - this.setState( { inactiveContent: themes.map( (item) => - - { item.trim().split( "," )[0] } - { item.trim().split( "," )[2] } - { item.trim().split( "," )[3] } - ) } ) - } else { - this.setState( { inactiveContent: - - No inactive themes. - - - - - } ) - } - } - } ); - - this.setState( { content: null} ) + // IMPORTANT can't forget to escape any spaces in dockerPath! + let inactiveCommand = `${ context.environment.dockerPath.replace(/ /g, "\\ ") } exec ${site.container} wp theme 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: + + Error retrieving inactive theme:
{ stderr }
+ - + - + } ) + } else { + // split list into array + let themes = stdout.trim().split( "\n" ) + themes.splice(0, 1) + + // Only create unordered list if there are themes to list + if ( themes.length && themes[0].length > 1 ) { + this.setState( { inactiveContent: themes.map( (item) => + + { item.trim().split( "," )[0] } + { item.trim().split( "," )[2] } + { item.trim().split( "," )[3] } + ) } + ) + } else { + this.setState( { inactiveContent: + + No inactive themes. + - + - + } ) + } + } + } ); + + this.setState( { content: null} ) } - render() { - return ( + render() { + return (
{ this.state.content } -

Active Theme

+

Active Theme

- - - - - + + + + + - - - { this.state.activeContent } - + + { this.state.activeContent }
NameUpdateVersion
NameUpdateVersion
-

Inactive Themes

+

Inactive Themes

- - - - - + + + + + - { this.state.inactiveContent } + { this.state.inactiveContent }
NameUpdateVersion
NameUpdateVersion
-
- ); - } + + ); } - + } }