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

playcanvas-tools

v0.8.9

Published

The PlayCanvas Command Line Tools.

Downloads

10

Readme

日本語 (Japanese README.md)

PlayCanvas CLI

This is a repository of tools that can be used when using the PlayCanvas editor.

Install from npm package

yarn global add playcanvas-tools

Command List

  • init: This command is used to perform initial setup of a project or application. It creates a configuration file interactively. PlayCanvas API key is required. This command needs to be executed before using the download | upload | archive commands.
  • download: This command places the PlayCanvas project in the current directory. It downloads a file with the same content as PlayCanvas Editor's DOWNLOAD.ZIP. It is downloaded under the folder name specified by playcanvas.json's projectName.
  • upload: This command takes a URL as an argument and uploads it to PlayCanvas (created mainly for the purpose of uploading files from Gist). It is uploaded to the PlayCanvas folder specified by playcanvas.json's remotePath.
  • archive: This command exports the PlayCanvas project. It is downloaded under the folder name specified by playcanvas.json's projectName.
  • sw: This command creates a ServiceWorker.js file containing a list of files to cache offline in a PWA. This command must be executed within the PlayCanvas files after downloading.
  • webp: This command converts images (png, jpg, gif) in the PlayCanvas project to the webp format. Compressed textures such as basis are skipped. This command must be executed within the PlayCanvas files after downloading.

playcanvas-cli init

Create a config file (playcanvas.json)

playcanvas-cli init

Arguments (optional)

  • -t token
  • -p projectId
  • -s scenes
  • -b branchId
  • -n projectName
  • -r remotePath

The generated playcanvas.json looks like this:

{
	"accessToken":"xxxxxxxxxxxx",
	"scenes":[xxxxx],
	"projectId":xxxxx,
	"branchId":"xxxxxx-xxxxx-xxxxx-xxxxx",
	"projectName":"xxxxx",
	"remotePath":"xxxxx"
}                                              

However, it is also possible to generate this file without running this command.

playcanvas-cli download

Download project based on download command playcanvas.json

cd projectname
playcanvas-cli download

playcanvas-cli upload

Upload asset from URL

playcanvas-cli upload -u https://gist.github.com/yushimatenjin/7276ad9f21492197f8ab5dbfbe092d36#file-translate-ja-js

playcanvas-cli archive

playcanvas-cli archive

playcanvas-cli sw

PlayCanvas Editor project to PWA. sw command serviceWorker.js for offline caching

1. playcanvas-cli sw

playcanvas-cli sw --name cachename

or

npx playcanvas-tools sw --name cachename

2. Load serviveWorker from index.html

<!-- index.html -->
...
<script>
if ("serviceWorker" in navigator) {
    navigator.serviceWorker.register("./serviceWorker.js").then(function (registration) {
            if (typeof registration.update == "function") {
                registration.update();
            }
        })
        .catch(function (error) {
            console.log("Error Log: " + error);
        });
}
</script>
...

3. Change the value of manifest.json

https://developer.mozilla.org/ja/docs/Mozilla/Add-ons/WebExtensions/manifest.json

{
    "name": "**projectname**",
    "short_name": "**projectname**",
    "icons": [
      {
        "src": "**logo**",
        "sizes": "192x192",
        "type": "image/png"
      }
    ],
    "start_url": "./index.html",
    "display": "standalone",
    "background_color": "#f16625",
    "theme_color": "#f16625"
  }

playcanvas-cli webp

Convert to WebP

playcanvas-cli webp -q 80 --alphaQuality 100  --nearLossless 100 --smartSubsample false --font true --texture true --textureatlas true --removeSource false --configFilePath ./config.json --outputConfigFilePath ./config_webp.json

or

npx playcanvas-tools  webp -q 80 --alphaQuality 100  --nearLossless 100 --smartSubsample false --font true --texture true --textureatlas true --removeSource false --configFilePath ./config.json --outputConfigFilePath ./config_webp.json

WebP Config

  • --quality -q # default 80
  • --alphaQuality # Quality of alpha layer, number from 0-100 (optional, default 100)
  • --lossless -l # Use near_lossless compression mode (optional, default undefined(font: true, texture:false, textureatlas:false) | true | false)
  • --nearLossless # Near lossless encoding, number from 0-100 (optional, default 100)
  • --smartSubsample # Use smart subsampling (optional, default false)

full document

Convert Options

  • --font # font assets for conversion. ( default true ) ※ Please set it to false when using large Japanese.
  • --texture # texture assets for conversion ( default true )
  • --textureatlas # textureatlas assets for conversion ( default true )
  • --removeSource # remove source file after conversion ( default false )
  • --configFilePath # config file path default ./config.json
  • --outputConfigFilePath # output config file path default ./config_webp.json

Create playcanvas.json from CI

You can create it interactively with the playcanvas-cli init command, but you can create playcanvas.json by entering it as a one-line command in CI etc.

Examples - CircleCI

 --------
 $ playcanvas-cli --accessToken "$PLAYCANVAS_ACCESS_TOKEN" --projectId "$PLAYCANVAS_PROJECT_ID" --scenes "$PLAYCANVAS_SCENES" --branchId "PLAYCANVAS_BRANCH_ID" --projectId "$PLAYCANVAS_PROJECT_ID" --remotePath "$PLAYCANVAS_REMOTE_PATH"