npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cartona/deploy-capacitor

v0.0.12

Published

Live updates for Ionic apps

Downloads

6

Readme

@cartona/capacitor-deploy

Live updates for Ionic apps. Inspired by ideas from Microsoft's CodePush and Cap-go/capacitor-updater.

Currently supported in both Android and iOS.

Not yet tested for use in Production environments.

Install

npm install @cartona/deploy-capacitor
npx cap sync

Example

The DeployClient class allows control of every step of the update process.

You can check, download, and install updates in one step (e.g. at startup) or split it over phases (e.g. on application state change).

import { DeployClient, AppBuild, DeployConfig } from '@cartona/deploy-capacitor';
...

async checkUpdates() {

    // Prepare global configuration

    let config: DeployConfig = {
        server_url: 'https://deploy-api.cartona.space',
        appcode: '<application identifier used to upload and rollout>',
        native_build: '<native app version number can be obtained by a Capacitor plugin>'
    }

    // MUST call startup() with application start

    await DeployClient.startup(config);

    // Check if any updates are available for this app on this device
    // You may show your Splash screen if this method returns a pending build
    // Then remove the Splash screen once the install is successful

    const found = await DeployClient.checkLatest();

    if (found) {
        // If a build needs to be installed, download it
        // If this is not the first update, a delta build will be fetched
        // You should call this on startup or only if the app status is active

        const local = await DeployClient.download(found);

        if (local) {
            // If the download is successful, install the bundle
            // This automatically restarts the web view
            // You may call this on startup or when the app status becomes inactive

            const ok = await DeployClient.install(local);

            if (ok) {
                console.log('Installed update!! ');
            } else {
                console.log('Failed to install update ');
            }
        }
    }
}

API

startup(...)

startup(config: DeployConfig) => Promise<void>

Initialize the client and load the latest installed build.

This MUST be called IMMEDIATELY on application startup.

| Param | Type | Description | | ------------ | ----------------------------------------------------- | ------------------------------- | | config | DeployConfig | the global configuration to use |


getDeployConfig()

getDeployConfig() => Promise<DeployConfig>

Fetch the current configuration of DeployClient

including the read-only device_id and current_build values

Returns: Promise<DeployConfig>


checkLatest()

checkLatest() => Promise<AppBuild | null>

Request the latest build available for download, if any.

Returns: Promise<AppBuild | null>


download(...)

download(latest: AppBuild) => Promise<AppBuild>

Download a build from the deploy-api server.

| Param | Type | Description | | ------------ | --------------------------------------------- | --------------------- | | latest | AppBuild | the build to download |

Returns: Promise<AppBuild>


install(...)

install(latest: AppBuild) => Promise<DeployResult>

Install a downloaded build and apply immediately.

This forces an immediate reload of the web view.

| Param | Type | Description | | ------------ | --------------------------------------------- | -------------------- | | latest | AppBuild | the build to install |

Returns: Promise<DeployResult>


reload()

reload() => Promise<DeployResult>

Reload the web view using the latest installed bundle.

You normally don't call this function. This is automatically called after an install.

Returns: Promise<DeployResult>


confirmInstall(...)

confirmInstall(latest: AppBuild) => Promise<DeployResult>

Register the current build on the deploy-api server.

You normally don't call this function. This is automatically called after a successful reload.

| Param | Type | Description | | ------------ | --------------------------------------------- | -------------------- | | latest | AppBuild | the build to confirm |

Returns: Promise<DeployResult>


rollback(...)

rollback(latest: AppBuild) => Promise<DeployResult>

Return to the prior build (i.e. UNDO an install).

You normally don't call this function. This is automatically called after a failed reload.

| Param | Type | Description | | ------------ | --------------------------------------------- | ----------------- | | latest | AppBuild | the build to undo |

Returns: Promise<DeployResult>


Interfaces

DeployConfig

Global configuration for all methods.

This MUST be provided at the first method call.

| Prop | Type | Description | | ------------------- | ------------------- | ------------------------------------------------------------------------ | | server_url | string | Base url for Cartona deploy-api server <protocol>://<domain> | | appcode | string | Application identifier (used to upload and rollout builds) | | username | string | Optional user name | | device_id | string | Device identifier (set automatically) | | current_build | number | Installed build number (set automatically) | | native_build | string | Native app version number (set manually or by using Capacitor plugin) |

AppBuild

Application version (Build) metadata.

This is fetched whenever a new build is available for download.

| Prop | Type | Description | | ------------------ | ------------------- | ---------------------------------------------------------- | | id | string | Unique build identifier | | appcode | string | Application identifier (used to upload and rollout builds) | | build | number | Build number | | download_url | string | Url used to download the build bundle | | local_path | string | Local path used to save the build bundle |

DeployResult

Result of plugin calls

| Prop | Type | Description | | ----------- | -------------------- | ----------------------------------------------------------- | | ok | boolean | Holds true if the operation was successful, otherwise false | | error | string | Optional error message if the operation was not successful |