marcus

wireshell - an extendable ProcessWire command line interface

Recommended Posts

Unfortunately no estimated time of arrival on my side, feeling sickly for a couple of weeks now, and drowning in customer work. Can't allocate time. Sorry :/

  • Like 2

Share this post


Link to post
Share on other sites

@marcus,

No problem, thank you for your time on this and for your reply; I hope you feel better soon.

Regards,

Steve

  • Like 2

Share this post


Link to post
Share on other sites

I'm in the process of getting wireshell PW3 ready. But I think it could use a bit more testing before I'll finally push it into the master branch. So I started a RC branch just for this purpose. If someone wanted to try and test it – which I would really appreciate: here you go (or: checkout branch feature/devns) !

  • Like 9

Share this post


Link to post
Share on other sites

I tried almost every command, but haven't noticed any issues with PW3. Maybe some of the heavy users will notice something.

Thank you for this awesome CLI.  :)

  • Like 3

Share this post


Link to post
Share on other sites

Since I didn't see it mentioned in any changelogs, I just want to give a heads up to the new ability to import field values via JSON files, which @justb3a implemented in top notch quality after my fiddly proof-of-concept patch :) . I find this to be a major improvement, since it enables so much easier import of data from e.g. Drupal, so just wanted to make you all aware of it.

I have outlined in very broad broad terms how I went about transferring data from a Drupal 7 site, to processwire, in this post.

  • Like 4

Share this post


Link to post
Share on other sites

Battling to install devns:

  [RuntimeException]
  Error loading sha `devns`, curl request failed (status code: 0,
   url: https://raw.githubusercontent.com/ryancramerdesign/Proces
  sWire/devns/wire/core/ProcessWire.php).
  cURL error: SSL certificate problem: unable to get local issuer
   certificate

Any ideas? (Going to do manual method for now.)

Share this post


Link to post
Share on other sites

Good day!

I am playing with the new command and finding some inconsistencies:

  1. If something went wrong while installing, like wrong db credentials were provided, there is no way to start over again without downloading the whole repo once again. Should there be a --no-download flag or something like that. The best thing is to make it check the db connection before the download process or even make it interactive and allow reenter the db credentials?
  2. Even with a db connection error I still get this untruthful message in the end: Congratulations, ProcessWire has been successfully installed.
  3. It would be nice if a new db could be attempted to create if there is not one already.
  4. I still get an error in the end :(
    PHP Fatal error:  Class 'WireDatabaseBackup' not found in C:\Users\dxlab1\AppData\Roaming\Composer\vendor\wireshell\wireshell\src\Helpers\Installer.php on line 486

     

Share this post


Link to post
Share on other sites

I tried out wireshell and installed it. It seems to work but not when I try to use it on a existing local install. PW Version doesn't matter so far. I'm using MAMP Pro and can't get it to work and always get an error.

When using the mysql socket as explained I get:

Error: Exception: SQLSTATE[HY000] [2002] No such file or directory (in /Applications/MAMP/htdocs/pw28.ch/wire/core/ProcessWire.php line 293)

When using the "allow network access" option in MAMP and using 127.0.0.1 I get:

Error: Exception: SQLSTATE[HY000] [2002] Connection refused (in /Applications/MAMP/htdocs/pw28.ch/wire/core/ProcessWire.php line 293)

I'm not sure what to try.

 

Share this post


Link to post
Share on other sites

Hi Soma,

which version of MAMP do you use (3.5)? It's very hard to say what is failing here since my wireshell/MAMP experience is limited to two systems (both El Capitan).

Best,

marcus

 

Share this post


Link to post
Share on other sites
5 minutes ago, marcus said:

Hi Soma,

which version of MAMP do you use (3.5)? It's very hard to say what is failing here since my wireshell/MAMP experience is limited to two systems (both El Capitan).

Best,

marcus

 

Yes MAMP Pro 3.5 on ElCapitan.

Share this post


Link to post
Share on other sites
2 minutes ago, Soma said:

Yes MAMP Pro 3.5 on ElCapitan.

Hm. Same here, and working with the 127.0.0.1/"allow network access" thing. Have you tried szabesz' suggestion?

Share this post


Link to post
Share on other sites

I'm not sure I want to follow what is written there, renaming php doesn't even work. And I dont' want to modify .bash_profile.

Share this post


Link to post
Share on other sites

It's kinda weird I'm now again trying to use the MAMP options to allow network access. I removed the socket configs I did in mysql and php but mysql log says 

160830 15:37:00 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended
160830 15:37:02 mysqld_safe Starting mysqld daemon with databases from /Library/Application Support/appsolute/MAMP PRO/db/mysql
160830 15:37:02 [Warning] Setting lower_case_table_names=2 because file system for /Library/Application Support/appsolute/MAMP PRO/db/mysql/ is case insensitive
160830 15:37:02 [Note] Plugin 'FEDERATED' is disabled.
160830 15:37:02 InnoDB: The InnoDB memory heap is disabled
160830 15:37:02 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160830 15:37:02 InnoDB: Compressed tables use zlib 1.2.3
160830 15:37:02 InnoDB: Initializing buffer pool, size = 128.0M
160830 15:37:02 InnoDB: Completed initialization of buffer pool
160830 15:37:02 InnoDB: highest supported file format is Barracuda.
160830 15:37:02  InnoDB: Waiting for the background threads to start
160830 15:37:03 InnoDB: 5.5.42 started; log sequence number 6123988935
160830 15:37:03 [Note] Server hostname (bind-address): '127.0.0.1'; port: 8889
160830 15:37:03 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
160830 15:37:03 [Note] Server socket created on IP: '127.0.0.1'.
160830 15:37:03 [Note] Event Scheduler: Loaded 0 events
160830 15:37:03 [Note] /Applications/MAMP/Library/bin/mysqld: ready for connections.
Version: '5.5.42'  socket: '/Applications/MAMP/tmp/mysql/mysql.sock'  port: 8889  Source distribution

Weird thing is that there's no file : '/Applications/MAMP/tmp/mysql/mysql.sock'  in my case. never was.

Share this post


Link to post
Share on other sites
23 minutes ago, Soma said:

I'm not sure I want to follow what is written there, renaming php doesn't even work. And I dont' want to modify .bash_profile.

The cause of the error was this "N98 will be trying to use your Macs native PHP which isn't configured for MAMP's MySQL resulting in the database errors."

N98 is a phar file, just like wireshell. This worked for me:

Change directory to /usr/bin
cd /usr/bin
Change the name of the native php to keep a backup (just incase)
sudo mv php php.old
Create a symlink to your php version
sudo ln -s /Applications/MAMP/bin/php/php.[VERSION]/bin/php php

You can redo this, so you might want to try it just to see what happens.

Edited by szabesz
missing word "is"

Share this post


Link to post
Share on other sites

@szabesz It doesn't allow me to rename "php" to "php.old".

Share this post


Link to post
Share on other sites
4 minutes ago, Soma said:

@szabesz It doesn't allow me to rename "php" to "php.old".

Maybe because of System Integrity Protection

eg.: http://www.macworld.com/article/2986118/security/how-to-modify-system-integrity-protection-in-el-capitan.html

The mac I use for development is still running Yosemite, so I have not yet tried to apply this change on El Capitan. Note, that I use this change for wp-cli too (so, still on Yosemite).

Share this post


Link to post
Share on other sites

 

3 minutes ago, szabesz said:

Note, that I use this change for wp-cli too (so, still on Yosemite).

I even made a bash script to hack it:

Spoiler

#!/bin/bash
# This script swaps the system default php binary for MAMP's version or vice versa

set -e
date
START="\e[0;95m :: \e[0m"
BLED="\e[0;36m :: \e[0m"
RLED="\e[0;41m :: \e[0m"
GLED="\e[0;47m :: \e[0m"
DONE="\e[0;42m :: \e[0m"

VERSION="php5.4.34"

ls -la /usr/bin/php*
if [ ! -f  /usr/bin/php.original ]; then
    printf "$START The file called php.original is NOT found!\n"
    printf "$BLED Do you want to switch to MAMP $VERSION? (y/n): "
    read ANSWER
    if [ "$ANSWER" = "y" ]; then
        cd /usr/bin
        sudo mv php php.original
        sudo ln -s /Applications/MAMP/bin/php/$VERSION/bin/php php
        printf "$BLED PHP is symlinked to MAMP $VERSION\n"
    else
        printf "$RLED You DID NOT choose yes! Nothing has been changed.\n"
    fi
else 
    printf "$START The file called php.original IS found!\n"
    printf "$BLED Do you want to switch to system version? (y/n): "
    read ANSWER
    if [ "$ANSWER" = "y" ]; then
        cd /usr/bin
        sudo rm php
        sudo mv php.original php
        printf "$BLED Original system PHP is restored.\n"
    else
        printf "$RLED You DID NOT choose yes! Nothing has been changed.\n"
    fi
fi
ls -la /usr/bin/php*

printf "$DONE We have reached the end of the script!\n"

date
exit 0

 

 

  • Like 2

Share this post


Link to post
Share on other sites

wireshell 1.0.0  :)

Compatibility: ProcessWire 3.x

  • Prepares wireshell for ProcessWire 3.x, adds namespace support, only supports ProcessWire 3.x
  • Updates Github Repository: github.com/processwire/processwire
  • Improves module:upgrade command, if no argument is provided it just checks for upgrades
  • Extends new command, adds option --src=path/to/source to be able to use a pre-downloaded tgz/zip/folder
  • Extends status command, only shows database password if --pass option is provided, shows if an upgrade is available
  • Updates upgrade command, removes options dev and devns
  • Like 10

Share this post


Link to post
Share on other sites

Hey guys, great work on all of this! I really like having this option.

However, while testing the 1.0.0 version [Edit: On macOS Sierra 10.12] I ran into an issue with creating a new project using a zipped site profile: It seems Wireshell fails at extracting the profile zip due to incorrect permissions? (I did not use any older version before so I do not know if this is a new problem).  

I have exported a site profile using Ryans Site Profile Export module, and have confirmed this works on a new PW 3.0.35 project: when I set it up manually (downloading & unpacking the PW zip, unpacking my profile zip into the folder and going through manual installation of the project) everything works fine. 

Also I can create new projects using the built-in profiles correctly (ie. `wireshell new projectname --profile=blank` etc).  To be sure I even checked if I could sudo run the script but to no avail (bad idea anyway). 

Below is the (truncated) result:

weps:Server eelke$ wireshell new thijmentest2 --verbose --profile=ProjectGenerator/site-ember-pw-profile.zip


 Downloading ProcessWire...
   10.21 MB/10.21 MB ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  100%

 Preparing project...

 Extracting profile...

[2016-10-03 08:39:59] name.ERROR: Error: Directory /Users/eelke/Documents/Werk/Server/thijmentest2/site/assets/ must be writable. Please adjust the permissions before continuing. [] []
[2016-10-03 08:39:59] name.ERROR: Error: File /Users/eelke/Documents/Werk/Server/thijmentest2/site/config.php must be writable. Please adjust the permissions before continuing. [] []
[2016-10-03 08:39:59] name.ERROR: One or more errors were found above. We recommend you correct these issues before proceeding or contact ProcessWire support if you have questions or think the error is incorrect. But if you want to proceed anyway, click Continue below. [] []

(.. Wireshell project settings ..) 

[2016-10-03 08:40:51] name.ERROR: Please fix the error to further proceed [] []

Congratulations, ProcessWire has been successfully installed.
weps:Server eelke$

As a result, the entire installation fails. After running the script, the database is empty and this is the folder structure:

Schermafbeelding 2016-10-03 om 09.10.52.png

Any ideas?

Edit: Definitely a problem with unzipping files. Very simple command:

Schermafbeelding 2016-10-04 om 13.41.43.png

It seems to be macOS Sierra related, accidentally I ran into a same kind of problem this morning doing some Homebrew tasks.
(https://github.com/caskroom/homebrew-cask/pull/22002

The signature of Zip files has changed apparently. 
Running 'file -Izb -- ~/Server/ProjectGenerator/processwire-master.zip' on OS X 10.11 yields:

application/x-empty compressed-encoding=application/zip; charset=binary; charset=binary

But on macOS 10.12 all you get is:

application/zip; charset=binary


 

 

Share this post


Link to post
Share on other sites

This has nothing to do with the signature of the zip file. The zip file has not the right permissions to be extracted. Please change the owner (user) of the zip file.

As stated in the error message: ..or because the installer doesn't have enough permissions to uncompress and rename the package contents.

works for me:
-r-x------ 1 username staff 11M Oct 6 12:39 pw.zip

leads to the error message ProcessWire can't be installed because...:
-r-x------ 1 100 staff 11M Oct 6 12:39 pw.zip

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By louisstephens
      I have a repeater with a text field where I would like to use hanna code (to make it easier on the user) so the user can define the action of a image that is in the repeater. For example:
      1. The image should have an external link:
      - the user can just type in the url
      2. The image, when clicked, should be printable (using print.js)
      - the user can just type [[print_image]]
      That works just fine, but I am running into an "issue". The code I need to use to print is:
      onclick="printJS({printable: 'path_to_image', type: 'image'});" I can put that into the hanna code as plain text, but I have no idea how to get the image from the repeater item and pass to "path_to_image". Is this even possible?
    • By louisstephens
      I have a script that is pulling in a json feed (will be attached to a cron job later) which looks like:
      $http = new WireHttp(); // Get the contents of a URL $response = $http->get("feed_url"); if($response !== false) { $decodedFeed = json_decode($response); } Everything there works well and I can pull the id, title, status (updated, new, sold) and other items from the decoded feed in a foreach loop. My whole goal is to create pages from the feed, but if the page has already been created, with all the same exact items from the json feed, I will need to "skip" over it.
      So far, I am running into a roadblock with my checks. I guess I need to compare the json to all my pages and their values and:
      1. If an id already exists, check to see if a fields data has been updated and then update the page,
      2. If an id exists and all fields are unchanged, skip adding that page
       
      $http = new WireHttp(); // Get the contents of a URL $response = $http->get("feed_url"); if($response !== false) { $decodedFeed = json_decode($response); foreach($decodedFeed as $feed) { $u = new Page(); $u->template = $templates->get("basic-page"); $u->parent = $pages->get("/development/"); $u->name = $feed->title = $feed->id; $u->title = $feed->title; $u->status = $feed->status $u->body = $feed->title; $u->save(); $u->setOutputFormatting(false); } } else { echo "HTTP request failed: " . $http->getError(); } I am really just hung up on how to do the current page checks and matching them with the json field data.
    • By louisstephens
      So I was going to build a todo tracking app for myself to test/broaden my knowledge of processwire, and so far it has been taxing 😓.  My Site structure is:
      - Project One - Phase One - Task - Task - Task - Phase Two - Task - Task - Task So far it was pretty easy, I can easily foreach through the Project and get the phases with their tasks. However, it gets a bit muddled when I have more than one project as I was trying to have a dashboard where the content switches out to the selected project as opposed to accessing each project via their own url. How would yall handle this?
      My next hurdle is each task has a select field (for project status) that I want to update via ajax (for the smooth transitioning).
      Scenario: You finish a task, change the option from "new" to "completed", and an onclick changes the status drop down background to green (which I have working), but then posts/saves a field on the backend to the new option.
       
      I have a page called "Actions" set up with url segments using
      if ($config->ajax && $input->urlSegment1 == 'change-status') { //save update field on admin } However, I am a little fuzzy on how to actually pass the current page along with the new selected status to actually update the page (task). I guess I am not very far into my endeavor. Any help would be greatly appreciated.
    • By louisstephens
      So this is more or less just a question regarding best practices, and how to actually achieve this. I have an internal tool I built awhile ago that has just gotten very "trashed". The naming conventions are all out of whack due to trying to get something completed, and pages are just everywhere. The fields got really out of hand as well, but I believe I have found a much cleaner field structure with the Repeater Matrix and a few other ProFields.  I decided recently to rewrite the template structure and the fields from scratch to keep everything nice and neat, but then it hit me that I would need to move all the previous data over and populate the new fields etc.
      The current tree looks something like:
      Group Title - Section A (template "section") - Category One (template "category") - Category Two (template "category") - Section B (template "section") - Category One (template "category") - Category Two (template "category") Etc etc... The structure is pretty good, and I am thinking of keeping it as it serves my purpose. However, I now have about 140 Sections with child pages that I would hopefully like to move to different templates, as well as changing the child templates/mapping data to the new fields. The only fields I need to worry about are a few textareas, text fields, options field,  as well as 1 image filed.
      I guess my real question is, what is the best way to go about this "migration" via the api while keeping the parent/child structure. It would be ok to leave it as is and chip away at it if I were the only one using it, but unfortunately that is not the case. 
      I guess one approach would be to copy over the entire structure and make the move to the new templates/fields. Once we have verified all the data/templates are correct, we could remove the old structure and possibly rename the new to mirror the old. However, this might just be too complicated.
    • By EyeDentify
      Hello Fellow PW Fans and Gurus.

      I have run into a problem where i have created a template without a template file associated with it.
      Now i would like to HAVE a template file associated with it, not an alternate but as the main template file.

      So i thought, that's easy, I upload the template file and change it in template settings but I only get the Alternate template file setting?

      Ok so maybe i can change it via the API , so i wrote some code for this.
      <?PHP function changeTemplate($pages = null, $templates = null) { /* get the pages to change template on */ $logItems = $pages->findMany('template=tmp_log_item'); /* get the template object for our desired template */ $Template = $templates->get('tmp_new_log_item'); foreach($logItems AS $key => $logData) { /* use template object $Template to set template */ $logData->template = $Template; /* save page item */ $logData->save(); } } /* do the magic change */ changeTemplate(); ?> Needless to say, PW was not happy about this, It throw up an error message:
      Error: Exception: Invalid value sent to Page::setTemplate (in /home/virtual/mydomain/public_html/wire/core/Page.php line 1782)
      Now from what i understand i gave $logData->template the wrong type of value.
      So what should the value be to correct this?
      When I read the docs at: https://processwire.com/api/ref/page/
      the value can be "string" or "Template".

      So i gave it a string and it went haywire.

      How should I approach this cause I realy dont want to manually change template file on över 50 plus pages

      Maybe I should use the Template class to create the value that the API wanted, but I am unsure how to use it.

      Thank you for any info you can give me on this.

      If you want more info to help me, ask and I will try my best to give it to you.
      Updated and Solved
      I solved the problem and have updated the code to reflect this.

      Essentialy i used the get() method of $templates to get the template object for my template i wanted to use using the template name.
      I gave the Object to the $logData->template property and all went well.
      We learn something new every day.
      One Note:
      The template file you want to use must have been uploaded and added as a template in the Template section in the Admin for this code to work as expected.