Re: [EXTERNAL] Re: Clear the cache strategy

2023-03-10 Thread Hugo Ferreira
I'm using a VS Code Extension "Run Terminal Command".
I'm using macOS environment
I'm using jq macOS terminal app (this app is usefull to grab variables from
a json file with a simple command)

Unfortunately, this extension does not support multiple command, so I end
up doing everthing in a single line !

This is my plugin configuration (to run with a single rigth click in the
build/release folder):
"runTerminalCommand.commands": [
{
"command": "rm -r .DS_Store RoyaleFramework.swc App.js.map pt org
resources/themes resources/index-template.html resources/styles.less
resources/images/BackgroundBuilding_Original.png && export
royale_app_version=`jq -r '.version' {resource}/../../asconfig.json` && sed
-i '' \"s/App.js/App.js?v=$royale_app_version/g\" index.html && zip -r
/Volumes/macOS/Users/hugo/Desktop/gc.zip {resource}",
"auto": true,
"preserve": true,
"group": "Post Build Apache Royale"
}
]

The comand runs:
1. Clean unwanted files
2. I have the version on the project file, so grab that to a environment
variable
3. Inject the variable in the index.html
4. Zip everything and put (hardcoded path) on my desktop folder

Hugo Ferreira  escreveu no dia sexta, 10/03/2023
à(s) 10:08:

> Thanks.
> On my case, I don't use maven but I see that the majority of us, have the
> same problem and each one applies is own script.
>
> Brian Raymes  escreveu no dia sexta, 10/03/2023
> à(s) 00:59:
>
>> If you use Maven, you can the maven-replacer-plugin to automate the
>> version/timestamp/build/etc for every build. One could also filter out
>> things such unwanted files like .DS_Store with other plugins.
>>
>> For instance:
>>  . . .
>>  ${maven.build.timestamp}
>>  . . .
>>   
>> 
>>   
>> com.google.code.maven-replacer-plugin
>> replacer
>> ${google.replacer.version}
>> 
>>   
>> prepare-package
>> 
>>   replace
>> 
>>   
>> 
>> 
>>   false
>>   ${compiler.output-dir}/index.html
>>   
>> 
>>   
>> 
>>   
>>   
>> 
>>   
>> 
>> 
>>   
>>         
>>   
>>   
>> 
>>   
>> 
>>   
>> 
>>   
>>  . . .
>>
>> Brian
>>
>> -Original Message-
>> From: Hugo Ferreira 
>> Sent: Thursday, March 9, 2023 4:30 PM
>> To: dev@royale.apache.org
>> Subject: [EXTERNAL] Re: Clear the cache strategy
>>
>> I found this VS Code extension:
>>
>> https://marketplace.visualstudio.com/items?itemName=adrianwilczynski.terminal-commands
>> With this I'm writing a script, so then after build-release, right-click
>> on the release folder to clean files and inject the version.
>>
>> Hugo Ferreira  escreveu no dia sexta, 10/03/2023
>> à(s) 00:05:
>>
>> > Thank you all.
>> > You all gave me greate ideas.
>> > Josh, no need to spend time on this.
>> > I will create my own script (remove the .DS files is also a good idea
>> > - I hate the mac pollute all my folders with that).
>> >
>> > Harbs  escreveu no dia quinta, 9/03/2023 à(s)
>> > 21:56:
>> >
>> >> Yes. My script also has some "aws s3 sync", "aws s3 cp” and "aws
>> >> cloudfront create-invalidation” commands to upload the app after
>> >> updating the version info.
>> >>
>> >> The sync commands (for the whole release directory has these arguments:
>> >>
>> >>  --exclude "*.DS_Store*" --delete --cache-control max-age=2592000
>> >> --acl public-read
>> >>
>> >> The cp command for the index.html file has these arguments:
>> >>
>> >>  --metadata-directive REPLACE --cache-control max-age=60,public
>> >> --content-type text/html --acl public-read
>> >>
>> >>
>> >> > On Mar 9, 2023, at 11:42 PM, Hugo Ferreira 
>> >> wrote:
>> >> >
>> >> > Thank you.
>> >> >
>> >> > OK,

Re: [EXTERNAL] Re: Clear the cache strategy

2023-03-10 Thread Hugo Ferreira
Thanks.
On my case, I don't use maven but I see that the majority of us, have the
same problem and each one applies is own script.

Brian Raymes  escreveu no dia sexta, 10/03/2023
à(s) 00:59:

> If you use Maven, you can the maven-replacer-plugin to automate the
> version/timestamp/build/etc for every build. One could also filter out
> things such unwanted files like .DS_Store with other plugins.
>
> For instance:
>  . . .
>  ${maven.build.timestamp}
>  . . .
>   
> 
>   
> com.google.code.maven-replacer-plugin
> replacer
> ${google.replacer.version}
> 
>   
> prepare-package
> 
>   replace
> 
>   
> 
> 
>   false
>   ${compiler.output-dir}/index.html
>   
> 
>   
> 
>   
>   
> 
>   
> 
> 
>   
> 
>   
>   
> 
>   
> 
>   
> 
>   
>  . . .
>
> Brian
>
> -Original Message-
> From: Hugo Ferreira 
> Sent: Thursday, March 9, 2023 4:30 PM
> To: dev@royale.apache.org
> Subject: [EXTERNAL] Re: Clear the cache strategy
>
> I found this VS Code extension:
>
> https://marketplace.visualstudio.com/items?itemName=adrianwilczynski.terminal-commands
> With this I'm writing a script, so then after build-release, right-click
> on the release folder to clean files and inject the version.
>
> Hugo Ferreira  escreveu no dia sexta, 10/03/2023
> à(s) 00:05:
>
> > Thank you all.
> > You all gave me greate ideas.
> > Josh, no need to spend time on this.
> > I will create my own script (remove the .DS files is also a good idea
> > - I hate the mac pollute all my folders with that).
> >
> > Harbs  escreveu no dia quinta, 9/03/2023 à(s)
> > 21:56:
> >
> >> Yes. My script also has some "aws s3 sync", "aws s3 cp” and "aws
> >> cloudfront create-invalidation” commands to upload the app after
> >> updating the version info.
> >>
> >> The sync commands (for the whole release directory has these arguments:
> >>
> >>  --exclude "*.DS_Store*" --delete --cache-control max-age=2592000
> >> --acl public-read
> >>
> >> The cp command for the index.html file has these arguments:
> >>
> >>  --metadata-directive REPLACE --cache-control max-age=60,public
> >> --content-type text/html --acl public-read
> >>
> >>
> >> > On Mar 9, 2023, at 11:42 PM, Hugo Ferreira 
> >> wrote:
> >> >
> >> > Thank you.
> >> >
> >> > OK, after you build-release you run a script that does exactly that.
> >> >
> >> > Harbs  escreveu no dia quinta, 9/03/2023
> >> > à(s)
> >> 21:37:
> >> >
> >> >> I have a bash script to stage my app that looks like this:
> >> >>
> >> >> version=$(cat $DIR/releases.json | jq '.version')
> >> >> version="${version%\"}"
> >> >> version="${version#\"}"
> >> >>
> >> >> build=$(node -e 'console.log(Date.now())') jq '.build = '$build
> >> >> releases.json > tmp.$$.json && mv tmp.$$.json releases.json
> >> >>
> >> >> sed -ie "s/MyApp.js/MyApp.js?{build_number}/g"
> >> bin/js-release/index.html
> >> >> sed -ie "s/{build_number}/$build/g" bin/js-release/index.html sed
> >> >> -ie "s/{version_number}/$version/g" bin/js-release/index.html
> >> >>
> >> >> releases.json has the version and the build number is updated by
> >> >> this script.
> >> >>
> >> >> The template html has this:
> >> >>
> >> >>
> >> >>
> >> >> >> >> href="${application}.css?{build_number}">
> >> >>
> >> >> The HTML file on the server has a very short TTL. The rest of the
> >> >> files have a much longer TTL. The build script busts the cache
> >> >> when it’s
> >> deployed.
> >> >>
> >> >> Change “MyApp” to the name of your app.
> >> >>
> >> >> HTH,
> >> >> Harbs
> >> >>
> >> >>
> >> >>> On Mar 9, 2023, at 10:43 PM, Hugo Ferreira
> >> >>> 
> >> >> wrote:
> >> >>>
> >> >>> Hi,
> >> >>>
> >> >>> I'm releasing now updates more often and sometimes (many times),
> >> >>> the browser cache my App.js In a quick google search I found a
> >> >>> solution (more a workaround) =>
> >> >>>
> >> >>
> >> https://stackoverflow.com/questions/1011605/clear-the-cache-in-javasc
> >> ript
> >> >>> When I build - release with VS Code, it inject this line on my
> >> >>> html file:
> >> >>> So, I don't have control over it.
> >> >>>
> >> >>> What I would like to do is something like have a version flag of
> >> >>> my
> >> App
> >> >> in
> >> >>> the asconfig.json and when I build - relase the compiler inject
> >> something
> >> >>> like:
> >> >>>  ...
> >> >>>
> >> >>> This is possible today ?
> >> >>>
> >> >>> Regards,
> >> >>> Hugo.
> >> >>
> >> >>
> >>
> >>
>


RE: [EXTERNAL] Re: Clear the cache strategy

2023-03-09 Thread Brian Raymes
If you use Maven, you can the maven-replacer-plugin to automate the 
version/timestamp/build/etc for every build. One could also filter out things 
such unwanted files like .DS_Store with other plugins.

For instance:
 . . .
 ${maven.build.timestamp}
 . . .
  

  
com.google.code.maven-replacer-plugin
replacer
${google.replacer.version}

  
prepare-package

  replace

  


  false
  ${compiler.output-dir}/index.html
  

  

  
  

  


  

  
  

  

  

  
 . . .

Brian

-Original Message-
From: Hugo Ferreira  
Sent: Thursday, March 9, 2023 4:30 PM
To: dev@royale.apache.org
Subject: [EXTERNAL] Re: Clear the cache strategy

I found this VS Code extension:
https://marketplace.visualstudio.com/items?itemName=adrianwilczynski.terminal-commands
With this I'm writing a script, so then after build-release, right-click on the 
release folder to clean files and inject the version.

Hugo Ferreira  escreveu no dia sexta, 10/03/2023
à(s) 00:05:

> Thank you all.
> You all gave me greate ideas.
> Josh, no need to spend time on this.
> I will create my own script (remove the .DS files is also a good idea 
> - I hate the mac pollute all my folders with that).
>
> Harbs  escreveu no dia quinta, 9/03/2023 à(s)
> 21:56:
>
>> Yes. My script also has some "aws s3 sync", "aws s3 cp” and "aws 
>> cloudfront create-invalidation” commands to upload the app after 
>> updating the version info.
>>
>> The sync commands (for the whole release directory has these arguments:
>>
>>  --exclude "*.DS_Store*" --delete --cache-control max-age=2592000 
>> --acl public-read
>>
>> The cp command for the index.html file has these arguments:
>>
>>  --metadata-directive REPLACE --cache-control max-age=60,public 
>> --content-type text/html --acl public-read
>>
>>
>> > On Mar 9, 2023, at 11:42 PM, Hugo Ferreira 
>> wrote:
>> >
>> > Thank you.
>> >
>> > OK, after you build-release you run a script that does exactly that.
>> >
>> > Harbs  escreveu no dia quinta, 9/03/2023 
>> > à(s)
>> 21:37:
>> >
>> >> I have a bash script to stage my app that looks like this:
>> >>
>> >> version=$(cat $DIR/releases.json | jq '.version') 
>> >> version="${version%\"}"
>> >> version="${version#\"}"
>> >>
>> >> build=$(node -e 'console.log(Date.now())') jq '.build = '$build 
>> >> releases.json > tmp.$$.json && mv tmp.$$.json releases.json
>> >>
>> >> sed -ie "s/MyApp.js/MyApp.js?{build_number}/g"
>> bin/js-release/index.html
>> >> sed -ie "s/{build_number}/$build/g" bin/js-release/index.html sed 
>> >> -ie "s/{version_number}/$version/g" bin/js-release/index.html
>> >>
>> >> releases.json has the version and the build number is updated by 
>> >> this script.
>> >>
>> >> The template html has this:
>> >>
>> >>
>> >>
>> >>> >> href="${application}.css?{build_number}">
>> >>
>> >> The HTML file on the server has a very short TTL. The rest of the 
>> >> files have a much longer TTL. The build script busts the cache 
>> >> when it’s
>> deployed.
>> >>
>> >> Change “MyApp” to the name of your app.
>> >>
>> >> HTH,
>> >> Harbs
>> >>
>> >>
>> >>> On Mar 9, 2023, at 10:43 PM, Hugo Ferreira 
>> >>> 
>> >> wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> I'm releasing now updates more often and sometimes (many times), 
>> >>> the browser cache my App.js In a quick google search I found a 
>> >>> solution (more a workaround) =>
>> >>>
>> >>
>> https://stackoverflow.com/questions/1011605/clear-the-cache-in-javasc
>> ript
>> >>> When I build - release with VS Code, it inject this line on my 
>> >>> html file: 
>> >>> So, I don't have control over it.
>> >>>
>> >>> What I would like to do is something like have a version flag of 
>> >>> my
>> App
>> >> in
>> >>> the asconfig.json and when I build - relase the compiler inject
>> something
>> >>> like: 
>> >>>  ...
>> >>>
>> >>> This is possible today ?
>> >>>
>> >>> Regards,
>> >>> Hugo.
>> >>
>> >>
>>
>>


Re: Clear the cache strategy

2023-03-09 Thread Hugo Ferreira
I found this VS Code extension:
https://marketplace.visualstudio.com/items?itemName=adrianwilczynski.terminal-commands
With this I'm writing a script, so then after build-release, right-click on
the release folder to clean files and inject the version.

Hugo Ferreira  escreveu no dia sexta, 10/03/2023
à(s) 00:05:

> Thank you all.
> You all gave me greate ideas.
> Josh, no need to spend time on this.
> I will create my own script (remove the .DS files is also a good idea - I
> hate the mac pollute all my folders with that).
>
> Harbs  escreveu no dia quinta, 9/03/2023 à(s)
> 21:56:
>
>> Yes. My script also has some "aws s3 sync", "aws s3 cp” and "aws
>> cloudfront create-invalidation” commands to upload the app after updating
>> the version info.
>>
>> The sync commands (for the whole release directory has these arguments:
>>
>>  --exclude "*.DS_Store*" --delete --cache-control max-age=2592000 --acl
>> public-read
>>
>> The cp command for the index.html file has these arguments:
>>
>>  --metadata-directive REPLACE --cache-control max-age=60,public
>> --content-type text/html --acl public-read
>>
>>
>> > On Mar 9, 2023, at 11:42 PM, Hugo Ferreira 
>> wrote:
>> >
>> > Thank you.
>> >
>> > OK, after you build-release you run a script that does exactly that.
>> >
>> > Harbs  escreveu no dia quinta, 9/03/2023 à(s)
>> 21:37:
>> >
>> >> I have a bash script to stage my app that looks like this:
>> >>
>> >> version=$(cat $DIR/releases.json | jq '.version')
>> >> version="${version%\"}"
>> >> version="${version#\"}"
>> >>
>> >> build=$(node -e 'console.log(Date.now())')
>> >> jq '.build = '$build releases.json > tmp.$$.json && mv tmp.$$.json
>> >> releases.json
>> >>
>> >> sed -ie "s/MyApp.js/MyApp.js?{build_number}/g"
>> bin/js-release/index.html
>> >> sed -ie "s/{build_number}/$build/g" bin/js-release/index.html
>> >> sed -ie "s/{version_number}/$version/g" bin/js-release/index.html
>> >>
>> >> releases.json has the version and the build number is updated by this
>> >> script.
>> >>
>> >> The template html has this:
>> >>
>> >>
>> >>
>> >>> >> href="${application}.css?{build_number}">
>> >>
>> >> The HTML file on the server has a very short TTL. The rest of the files
>> >> have a much longer TTL. The build script busts the cache when it’s
>> deployed.
>> >>
>> >> Change “MyApp” to the name of your app.
>> >>
>> >> HTH,
>> >> Harbs
>> >>
>> >>
>> >>> On Mar 9, 2023, at 10:43 PM, Hugo Ferreira 
>> >> wrote:
>> >>>
>> >>> Hi,
>> >>>
>> >>> I'm releasing now updates more often and sometimes (many times), the
>> >>> browser cache my App.js
>> >>> In a quick google search I found a solution (more a workaround) =>
>> >>>
>> >>
>> https://stackoverflow.com/questions/1011605/clear-the-cache-in-javascript
>> >>> When I build - release with VS Code, it inject this line on my html
>> >>> file:
>> >>> So, I don't have control over it.
>> >>>
>> >>> What I would like to do is something like have a version flag of my
>> App
>> >> in
>> >>> the asconfig.json and when I build - relase the compiler inject
>> something
>> >>> like:
>> >>> 
>> >>> ...
>> >>>
>> >>> This is possible today ?
>> >>>
>> >>> Regards,
>> >>> Hugo.
>> >>
>> >>
>>
>>


Re: Clear the cache strategy

2023-03-09 Thread Hugo Ferreira
Thank you all.
You all gave me greate ideas.
Josh, no need to spend time on this.
I will create my own script (remove the .DS files is also a good idea - I
hate the mac pollute all my folders with that).

Harbs  escreveu no dia quinta, 9/03/2023 à(s) 21:56:

> Yes. My script also has some "aws s3 sync", "aws s3 cp” and "aws
> cloudfront create-invalidation” commands to upload the app after updating
> the version info.
>
> The sync commands (for the whole release directory has these arguments:
>
>  --exclude "*.DS_Store*" --delete --cache-control max-age=2592000 --acl
> public-read
>
> The cp command for the index.html file has these arguments:
>
>  --metadata-directive REPLACE --cache-control max-age=60,public
> --content-type text/html --acl public-read
>
>
> > On Mar 9, 2023, at 11:42 PM, Hugo Ferreira 
> wrote:
> >
> > Thank you.
> >
> > OK, after you build-release you run a script that does exactly that.
> >
> > Harbs  escreveu no dia quinta, 9/03/2023 à(s)
> 21:37:
> >
> >> I have a bash script to stage my app that looks like this:
> >>
> >> version=$(cat $DIR/releases.json | jq '.version')
> >> version="${version%\"}"
> >> version="${version#\"}"
> >>
> >> build=$(node -e 'console.log(Date.now())')
> >> jq '.build = '$build releases.json > tmp.$$.json && mv tmp.$$.json
> >> releases.json
> >>
> >> sed -ie "s/MyApp.js/MyApp.js?{build_number}/g" bin/js-release/index.html
> >> sed -ie "s/{build_number}/$build/g" bin/js-release/index.html
> >> sed -ie "s/{version_number}/$version/g" bin/js-release/index.html
> >>
> >> releases.json has the version and the build number is updated by this
> >> script.
> >>
> >> The template html has this:
> >>
> >>
> >>
> >> >> href="${application}.css?{build_number}">
> >>
> >> The HTML file on the server has a very short TTL. The rest of the files
> >> have a much longer TTL. The build script busts the cache when it’s
> deployed.
> >>
> >> Change “MyApp” to the name of your app.
> >>
> >> HTH,
> >> Harbs
> >>
> >>
> >>> On Mar 9, 2023, at 10:43 PM, Hugo Ferreira 
> >> wrote:
> >>>
> >>> Hi,
> >>>
> >>> I'm releasing now updates more often and sometimes (many times), the
> >>> browser cache my App.js
> >>> In a quick google search I found a solution (more a workaround) =>
> >>>
> >>
> https://stackoverflow.com/questions/1011605/clear-the-cache-in-javascript
> >>> When I build - release with VS Code, it inject this line on my html
> >>> file:
> >>> So, I don't have control over it.
> >>>
> >>> What I would like to do is something like have a version flag of my App
> >> in
> >>> the asconfig.json and when I build - relase the compiler inject
> something
> >>> like:
> >>> 
> >>> ...
> >>>
> >>> This is possible today ?
> >>>
> >>> Regards,
> >>> Hugo.
> >>
> >>
>
>


Re: Clear the cache strategy

2023-03-09 Thread Harbs
Yes. My script also has some "aws s3 sync", "aws s3 cp” and "aws cloudfront 
create-invalidation” commands to upload the app after updating the version info.

The sync commands (for the whole release directory has these arguments:

 --exclude "*.DS_Store*" --delete --cache-control max-age=2592000 --acl 
public-read

The cp command for the index.html file has these arguments:

 --metadata-directive REPLACE --cache-control max-age=60,public --content-type 
text/html --acl public-read


> On Mar 9, 2023, at 11:42 PM, Hugo Ferreira  wrote:
> 
> Thank you.
> 
> OK, after you build-release you run a script that does exactly that.
> 
> Harbs  escreveu no dia quinta, 9/03/2023 à(s) 21:37:
> 
>> I have a bash script to stage my app that looks like this:
>> 
>> version=$(cat $DIR/releases.json | jq '.version')
>> version="${version%\"}"
>> version="${version#\"}"
>> 
>> build=$(node -e 'console.log(Date.now())')
>> jq '.build = '$build releases.json > tmp.$$.json && mv tmp.$$.json
>> releases.json
>> 
>> sed -ie "s/MyApp.js/MyApp.js?{build_number}/g" bin/js-release/index.html
>> sed -ie "s/{build_number}/$build/g" bin/js-release/index.html
>> sed -ie "s/{version_number}/$version/g" bin/js-release/index.html
>> 
>> releases.json has the version and the build number is updated by this
>> script.
>> 
>> The template html has this:
>> 
>>
>>
>>> href="${application}.css?{build_number}">
>> 
>> The HTML file on the server has a very short TTL. The rest of the files
>> have a much longer TTL. The build script busts the cache when it’s deployed.
>> 
>> Change “MyApp” to the name of your app.
>> 
>> HTH,
>> Harbs
>> 
>> 
>>> On Mar 9, 2023, at 10:43 PM, Hugo Ferreira 
>> wrote:
>>> 
>>> Hi,
>>> 
>>> I'm releasing now updates more often and sometimes (many times), the
>>> browser cache my App.js
>>> In a quick google search I found a solution (more a workaround) =>
>>> 
>> https://stackoverflow.com/questions/1011605/clear-the-cache-in-javascript
>>> When I build - release with VS Code, it inject this line on my html
>>> file:
>>> So, I don't have control over it.
>>> 
>>> What I would like to do is something like have a version flag of my App
>> in
>>> the asconfig.json and when I build - relase the compiler inject something
>>> like:
>>> 
>>> ...
>>> 
>>> This is possible today ?
>>> 
>>> Regards,
>>> Hugo.
>> 
>> 



Re: Clear the cache strategy

2023-03-09 Thread Josh Tynjala
I think some JS bundling tools generate a short hash (like SHA or MD5)
based on the contents of the file. Just a possible alternative to using a
version string. The Royale compiler doesn't support doing anything like
that automatically, but I don't see why you couldn't write a shell script
to run a post-processing step after compiling.

If you want something supported by the Royale compiler, you'd probably need
to create a custom index.html template for the release build. Instead of
letting the compiler inject the  tag, you could hard-code it
manually.

--
Josh Tynjala
Bowler Hat LLC <https://bowlerhat.dev>


On Thu, Mar 9, 2023 at 12:43 PM Hugo Ferreira 
wrote:

> Hi,
>
> I'm releasing now updates more often and sometimes (many times), the
> browser cache my App.js
> In a quick google search I found a solution (more a workaround) =>
> https://stackoverflow.com/questions/1011605/clear-the-cache-in-javascript
> When I build - release with VS Code, it inject this line on my html
> file: