0.0.5 • Published 6 years ago

node-srutils v0.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

node-srutils

Authenticating

To use this tool, you must authenticate to the Reddit API. You must provide either:

  • (a) clientId, clientSecret, refreshToken
  • (b) clientId, clientSecret, username, password

To store the client ID and client secret token in the configuration file, you must run the config command. You can choose to enter either a refresh token in the config command or provide username and password on the command line.

Username/password authentication

Pass in your reddit username and password as options in the command line. If you have 2-Factor Authentication enabled, append your 2FA code to the end of your password with a colon (password:code).

node-srutils backup /r/<subreddit> --username <reddit-username> --password <reddit-password>

Refresh token

With the config command, you can save your OAuth refresh token to avoid having to authenticate manually on each run of the script. Your refresh token requires the following scopes:

  • flair
  • modconfig
  • modflair
  • mysubreddits
  • read
  • structuredstyles

Commands

config

Create a configuration file which contains OAuth credentials. Follow the prompts and provide the required information (client key, client secret, and optional refresh token). For more information on obtaining the required credentials, you can visit https://github.com/reddit-archive/reddit/wiki/OAuth2-Quick-Start-Example#first-steps and https://not-an-aardvark.github.io/reddit-oauth-helper/ for more information.

node-srutils config

reset

Resets a subreddit's settings and stylesheet back to default. You must be a moderator of the subreddit to run this command.

node-srutils reset /r/example [filters]
node-srutils reset /r/example            // to completely reset a subreddit to default
node-srutils reset /r/example all        // to completely reset a subreddit to default
node-srutils reset /r/example css,images // to reset stylesheet and stylesheet images
node-srutils reset /r/example flair      // to remove all flair settings and templates

The filters allow you to selectively reset parts of the subreddit. Filters may be all (by default) to clear all data, or any comma-separated combination of css, images, header, icon, banner, settings, and flair.` If no filters are specified, all of the filters will be applied.

clone

Clones the stylesheet and settings from one subreddit to another.

node-srutils clone /r/from /r/to

Settings and styles will first be reset to default in the destination subreddit, and then populated with the settings and styles from the source subreddit. You must be a moderator of the destination subreddit, and you must be able to view the styles and settings of the target subreddit.

backup

Creates a zip archive containing a subreddit's settings and styles.

node-srutils backup /r/example

Includes subreddit stylesheet, images, sidebar content, and flair templates.

restore

Restores a subreddit's settings and styles from a backup zip archive.

node-srutils restore valid_node_srutils_subreddit_backup.zip

Includes subreddit stylesheet, images, sidebar content, and flair templates.

Development

$ git clone https://github.com/emyarod/node-srutils.git
$ cd node-srutils
$ npm install
$ NODE_ENV=dev node bin/cli.js <command>