[SOLVED] Package for Postman (Windows/MacOS)

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
bastien30
Messages: 38
Registration: March 8, 2024 - 3:21 PM

October 30, 2024 - 10:56

Good morning,

If it's of any use, here's the package code I use for the Postman software:

For Windows:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
import time

uninstallkey = []

setup_path = r'C:\ProgramData\postman-installer'
bin_name = r'Postman-win64-Setup.exe'

def install():
    mkdirs(setup_path)
    filecopyto(bin_name, makepath(setup_path, bin_name))

def uninstall():
    for user_path in local_users_profiles():
        # Uninstall silently
        if isfile(makepath(user_path, r'\AppData\Local\Postman', r'Update.exe')):
            run_notfatal(r'"%s" --uninstall -s' % makepath(user_path, r'\AppData\Local\Postman', r'Update.exe'))
            time.sleep(2)
        # Remove local appdata dir
        if isdir(makepath(user_path, r'\AppData\Local\Postman')):
            remove_tree(makepath(user_path, r'\AppData\Local\Postman'))
    remove_tree(setup_path)
    
def session_setup():
    run(r'"%s" -s' % makepath(setup_path, bin_name))
    time.sleep(5)
    for i in range(30):
        if not isfile(makepath(user_local_appdata, r'\Postman\Update.exe')):
            time.sleep(5)
        else:
            break

def update_package():
    url = r'https://dl.pstmn.io/download/latest/win64'
    wget(url, bin_name)
    version_from_file = get_version_from_binary(bin_name)
    version_from_package = control.version.split('-')[0]

    if Version(version_from_file) > Version(version_from_package):
        print(r'Latest Postman version is %s' % version_from_file)
        # Changing version of the package
        control.version = '%s-%s' % (version_from_file, control.version.split('-', 1)[-1])
        control.save_control_to_wapt()
        print('Changing version to: %s in WAPT\\control' % control.version)
    else:
        print(r'Already up to date !')
For macOS:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = []

zip_name = r'Postman-MacOS-arm64.zip'
app_name = r'Postman.app'

def install():
    run(r'unzip -qq %s %s/*' % (zip_name, app_name))
    install_app(app_name)

def uninstall():
    uninstall_app(app_name)

def update_package():
    import plistlib
    if isdir(app_name):
        remove_tree(app_name)
    url = r'https://dl.pstmn.io/download/latest/osx_arm64'
    wget(url, zip_name)
    unzip(zip_name, target=r'', filenames=r'%s/*' % app_name)
    version_from_package = control.version.split('-')[0]
    plist_file = plistlib.readPlist(r'%s/Contents/Info.plist' % app_name)
    version_from_plist = plist_file[r'CFBundleShortVersionString']
    remove_tree(app_name)

    if Version(version_from_plist) > Version(version_from_package):
        print(r'Latest Postman version is %s' % version_from_plist)
        # Changing version of the package
        control.version = '%s-%s' % (version_from_plist, control.version.split('-', 1)[-1])
        control.save_control_to_wapt()
        print('Changing version to: %s in WAPT\\control' % control.version)
    else:
        print(r'Already up to date !')
User avatar
dcardon
WAPT Expert
Messages: 1931
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

November 6, 2024 - 12:00

Hi Bastien,

thanks for sharing. It looks like a pretty good piece of software; I think we'll use it internally too. :-)

Best regards,

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
fschelfaut
Messages: 30
Registration: Nov 7, 2024 - 12:22

November 8, 2024 - 3:26 PM

Hello Bastien,

We have packaged Postman for Windows and macOS. It is currently available in the PREPROD repository and will be accessible on the store in 5 days.

Here are the links to the PREPROD builds:

- Windows x64
- macOS Intel
- macOS ARM

Best regards,
Flavien
bastien30
Messages: 38
Registration: March 8, 2024 - 3:21 PM

November 8, 2024 - 4:43 PM

Hello,

Great, I'll wait until it's in the stable repository to check it out and probably replace my packages with yours :D

. Thank you.
bastien30
Messages: 38
Registration: March 8, 2024 - 3:21 PM

December 17, 2024 - 12:27

fschelfaut wrote: Nov 8, 2024 - 3:26 PM Hello Bastien,

We have packaged Postman for Windows and macOS. It is currently available in the PREPROD repository and will be accessible in the store in 5 days.

Here are the links to the PREPROD builds:

- Windows x64
- macOS Intel
- macOS arm

Best regards,
Flavien
Good morning,

I downloaded your packages instead of mine because they are cleaner (installation in program files).
However, I've noticed a small problem after a package update; under Windows, the program starts and then closes a few seconds later.

After investigation, it was due to the AppData\Roaming\Postman\storage\settings.json file in which there is a "lastKnownVersion" parameter which has the value of the previously installed version.
If we update the value with the new version, the program starts normally.

Would it be possible to add this modification to the package, please?
I think it would therefore be necessary to do this for all users.

Thanks in advance.
fschelfaut
Messages: 30
Registration: Nov 7, 2024 - 12:22

December 20, 2024 - 10:05 AM

Hi Bastien,

Thanks for your feedback! Indeed, I hadn't considered that file.
I've therefore adapted the code so that settings.json is automatically updated (session-setup).

You can find the package in PREPROD here.

Please let me know if this resolves your issue.

Flavien,
bastien30
Messages: 38
Registration: March 8, 2024 - 3:21 PM

December 20, 2024 - 5:11 PM

Thank you so much! :)
bastien30
Messages: 38
Registration: March 8, 2024 - 3:21 PM

December 26, 2024 - 5:11 PM

Hello,

I just updated Postman, everything works fine :D

. Thank you!
Locked