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

cpsync

v0.0.6

Published

Synchronize files from a CircuitPython device to a local project folder

Downloads

6

Readme

CircuitPython Sync

GitHub License GitHub package.json version GitHub Issues npm Downloads

Node module that synchronizes the files on a connected CircuitPython device to a local project folder. It provides a one-way sync from the CircuitPython device to the local project folder. Technically it does a copy rather than a sync, but if I included copy in the name, it would be cpcopy or cp-copy which looks like a merger of the Linux copy command cp plus the DOS copy command copy and that would be confusing.

When you work with a CircuitPython device, you generally read and write executable Python files directly from/to the device; there's even a Python editor called Mu built just for this use case.

Many more experienced developers work with a local project folder then transfer the source code to a connected device, as you do when working with Arduino and other platforms. This module allows you to do both:

  1. Read/write source code from/to a connected Circuit Python device using Mu or other editors (even Visual Studio Code plugins).
  2. Automatically copy source files from the device to a local project folder whenever the change on the device.

Here's how it works:

  1. Create a local Python project with all the other files you need (like a readme.md file, or a .gitignore).
  2. Connect a CircuitPython device to your computer.
  3. Open a terminal window or command prompt and execute the module specifying the CircuitPython drive path and local project path as command line arguments.
  4. The module copies all of the files from the connected CircuitPython device to the specified project folder.
  5. Open any editor you want and edit the Python source code files (and any other file) on the connected device.
  6. When you save any modified files on the connected CircuitPython device, the module automatically copies the modified file(s) to the project folder.

See the module in action on YouTube

Installation

To install globally, open a command prompt or terminal window and execute the following command:

npm install -g cpsync

You'll want to install globally since CircuitPython projects don't generally use Node modules (like this one) so a package.json file and node_modules folder will look weird in your project folder.

Usage

To start the sync process, in a terminal window execute the following command:

cpsync <device_path> <sync_path> [-d | --debug] [-i | --ignore]

Arguments:

  • <device_path> is the drive path for a connected CircuitPython device
  • <sync_path> is the local project folder where you want the module to copy the files from the connected CircuitPython device

Both command arguments are required (indicated by angle brackets < and >). Square brackets ([ and ])indicate optional parameters.

Options:

  • -d or --debug enables debug mode which writes additional information to the console as the module executes
  • -i or --ignore instructs the module to ignore the internal files typically found on a CircuitPython device.

A CircuitPython device hosts several internal use or housekeeping files that you don't need copied into your local project. When you enable ignore mode (by passing the -i option on the command line), the module ignores the following when synchronizing files from the CircuitPython device to your local project folder:

const ignoreFiles = [
  'boot_out.txt',
  'BOOTEX.LOG',
  '.DS_Store',
  '.metadata_never_index',
  'System Volume Information',
  'test_results.txt',
  '.Trashes'
] as const;

const ignoreFolders = [
  '.fseventsd',
  'System Volume Information',
  '.Trashes'
] as const;

If you find other device-side housekeeping files, let me know and I'll update the ignore arrays in the module.

Examples

If you don't want to install the module globally, you can execute the module on the fly instead using:

npx cpsync <device_path> <sync_path>

On Windows, the device appears as a drive with a drive letter assignment. So, assuming it's drive H (your experience may vary but that's how it shows up on my Windows system) start the module with the following command:

cpsync h: c:\dev\mycoolproject

Assuming you'll launch the module from your project folder, use a . for the current folder as shown in the following example:

cpsync h: .

On macOS, it mounts as a drive and you can access it via /Volumes folder. On my system, the device mounts as CIRCUITPY, so start the sync process using:

cpsync /Volumes/CIRCUITPY .

On Windows I like to execute the module from the terminal prompt in Visual Studio Code, but keep the terminal available to execute other commands, so I start the module using the following:

start cpsync <device_path> <sync_path>

This starts the module in a new/separate terminal window, leaving the Visual Studio terminal available to me to execute additional commands.

For example, if I execute the following command:

start cpsync h: . -i

A new window opens as shown in the following figure

Windows Terminal Example

The CircuitPython device shows up as drive H: and the . tells the module to copy the files to the current folder.

Every time you change the file contents on the device, the module copies the modified files to the local project folder.

Getting Help Or Making Changes

Use GitHub Issues to get help with this module.

Pull Requests gladly accepted, but only with complete documentation of what the change is, why you made it, and why you think its important to have in the module.

If this code helps you: