3

I'm trying to create a workflow for designing multiple Shopify themes based on the same theme. I have written a simple PowerShell script that collects the necessary files and compresses them into a zip file.

Here is a simplified version of my script:

# Copy all files from the base theme to my temporary folder
Copy-Item $baseTheme"*" $tempFolder -recurse -force -exclude ".git"

# Include the files specific to the current theme
Copy-Item $specificTheme"assets"    $tempFolder -recurse -force
Copy-Item $specificTheme"config"    $tempFolder -recurse -force
Copy-Item $specificTheme"layout"    $tempFolder -recurse -force
Copy-Item $specificTheme"snippets"  $tempFolder -recurse -force
Copy-Item $specificTheme"templates" $tempFolder -recurse -force

# Compress the temporary folder
Compress-Archive $tempFolder $zipFileName

When I manually perform these steps, and create the zip file in Windows using Send To > Compressed (zipped) folder, Shopify is completely happy with the zip file.

However, when I upload the result of this script it gives me the following error:

There was 1 error:

zip does not contain a valid theme: missing template "layout/theme.liquid", missing template "templates/index.liquid", missing template "templates/collection.liquid", missing template "templates/product.liquid", missing template "templates/page.liquid", missing template "templates/cart.liquid", and missing template "templates/blog.liquid"

I've double and triple checked the zip file, and all of the required files exist. I've messed around with the -CompressionLevel of Compress-Archive. I've tried other methods of zipping folders within PowerShell. All with no luck.

I really can't see any difference between the results of the script and compressing manually. Any ideas?

Community
  • 1
  • 1
Ghost Unit
  • 101
  • 2
  • 7
  • Maybe there is a certain folder structure expected in the archive ? – sodawillow Dec 13 '15 at 10:28
  • @sodawillow You're absolutely correct. As of now, I disabled the `Compress-Archive` line in my script and have it only create the folder structure. Next I manually zip the folder it creates and upload it to Shopify. This works perfectly.I think it's safe to say there's something about the zip coming out of PowerShell that is different than what Shopify is expecting. – Ghost Unit Dec 13 '15 at 10:51

2 Answers2

1

I am answering my own question, but I'm not the one that solved it. I posted a link to this question on the shopify forum and someone named Adrian posted the following answer.

Short version. Download 7-ZIP and use the test archive facility. Zips created with compress-archive show no folders whereas those created with the Send To zip in Windows do. The folders do exist inside the actual archive though so I'd say the header info is malformed.

Looks like there is a structural error within the files that compress-archive creates that Windows is happy with but the, probably Unix-based, Shopify servers don't accept.

I installed 7-Zip and used the Test Archive feature to evaluate both folders. Here is the (truncated) output:

Compressed with Compress-Archive

Archives: 1
Files: 77
There are no errors.

Compressed with Send-To Zip context menu

Archives: 1
Folders: 6
Files: 76
There are no errors.

At this point, I'm just happy knowing what's going on. But in order to really call this problem solved I updated my PowerShell script to use 7-Zip for compressing the folder.

I replaced this:

# Compress the temporary folder
Compress-Archive $tempFolder $zipFileName

With this:

# Compress the temporary folder
& "c:\Program Files\7-Zip\7z.exe" a -tzip $zipFile $tempFolder

I uploaded the archive to Shopify and everything worked just fine.

Now, I'm really not that excited about installing and running third party software to do what (I believe) should be a basic OS task. I've reported this issue to Microsoft here. Who knows, maybe they'll fix it.

Ghost Unit
  • 101
  • 2
  • 7
  • I just got an update from Microsoft: "This should be fixed this in the latest version of PowerShell 5.0 (available with WMF 5.0 and Windows 10 November Update)." – Ghost Unit Dec 22 '15 at 00:59
0

This looks like an issue with the folder structure inside the archive file.

If you inspect the archive file created via PowerShell, does it show the same structure as the file created manually ?

This link shows the expected folder structure for a Shopify Theme:

index.liquid
product.liquid
collection.liquid
cart.liquid
blog.liquid
article.liquid
page.liquid
list_collections.liquid
search.liquid
404.liquid
gift_cards.liquid
customers/account.liquid
customers/activate.liquid
customers/addresses.liquid
customers/login.liquid
customers/order.liquid
customers/register.liquid
customers/reset_password.liquid
password.liquid
settings_schema.json
theme.liquid (layout file)
sodawillow
  • 12,497
  • 4
  • 34
  • 44
  • I am certain the folder structure is correct. I disabled the `Compress-Archive` line in my script and have it only create the folder structure. When I manually zip and upload that folder it works perfectly.I think it's safe to say there's something about the zip coming out of PowerShell that is different than what Shopify is expecting. – Ghost Unit Dec 14 '15 at 00:16