template-archive icon indicating copy to clipboard operation
template-archive copied to clipboard

Should archive files be actually compressed?

Open jeromesimeon opened this issue 4 years ago • 2 comments

Discussion 🗣

I'm unclear that cicero archive used to create .cta files actually compresses them in the corresponding zip. Should the archive use compression?

Example with cicero archive:

zsh-5.8$ cicero archive 
8:13:38 AM - INFO: Using current directory as template folder
8:13:40 AM - INFO: Creating archive: [email protected]
zsh-5.8$ ls -la [email protected] 
-rw-r--r--  1 jeromesimeon  staff  36209 Jun 20 08:13 [email protected]

Example with zip -r:

zsh-5.8$ zip -r test.zip .
  adding: request.json (deflated 21%)
  adding: state.json (stored 0%)
  adding: test/ (stored 0%)
  adding: test/logic_default.feature (deflated 46%)
  adding: test/logic.feature (deflated 75%)
  adding: .cucumber.js (stored 0%)
  adding: logic/ (stored 0%)
  adding: logic/logic.ergo (deflated 51%)
  adding: README.md (deflated 20%)
  adding: package.json (deflated 58%)
  adding: logo.png (stored 0%)
  adding: model/ (stored 0%)
  adding: model/@models.accordproject.org.accordproject.runtime.cto (deflated 51%)
  adding: model/model.cto (deflated 62%)
  adding: model/@models.accordproject.org.organization.cto (deflated 49%)
  adding: model/@models.accordproject.org.geo.cto (deflated 67%)
  adding: model/@models.accordproject.org.accordproject.contract.cto (deflated 47%)
  adding: model/@models.accordproject.org.address.cto (deflated 47%)
  adding: text/ (stored 0%)
  adding: text/sample.md (deflated 51%)
  adding: text/grammar.tem.md (deflated 54%)
zsh-5.8$ ls -la test.zip
-rw-r--r--  1 jeromesimeon  staff  17131 Jun 20 08:13 test.zip

jeromesimeon avatar Jun 20 '21 12:06 jeromesimeon

There is a compression option on jszip which is STORE (no compression) by default https://stuk.github.io/jszip/documentation/api_jszip/generate_async.html

Option would presumable need to be added to this call: https://github.com/accordproject/cicero/blob/558978c230e1a774e587a26c47f83b9ef284e615/packages/cicero-core/src/templatesaver.js#L118

Default compression would simply need to use DEFLATE https://stuk.github.io/jszip/documentation/api_jszip/generate_async.html#compression-and-compressionoptions-options

jeromesimeon avatar Aug 24 '21 17:08 jeromesimeon

I had always assumed that this was what happens already!

Would this be a breaking change?

mttrbrts avatar Aug 24 '21 17:08 mttrbrts