{"id":13431787,"url":"https://github.com/acode/cli","last_synced_at":"2025-05-14T07:08:17.714Z","repository":{"id":42076976,"uuid":"65198752","full_name":"acode/cli","owner":"acode","description":"Autocode CLI and standard library tooling","archived":false,"fork":false,"pushed_at":"2023-09-21T07:08:12.000Z","size":427,"stargazers_count":3800,"open_issues_count":9,"forks_count":163,"subscribers_count":78,"default_branch":"master","last_synced_at":"2025-04-21T16:52:37.727Z","etag":null,"topics":["api","autocode","aws-lambda","faas","node","nodejs","registry","sdks","serverless","stdlib"],"latest_commit_sha":null,"homepage":"https://autocode.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-08-08T11:27:43.000Z","updated_at":"2025-04-04T00:15:19.000Z","dependencies_parsed_at":"2024-01-13T10:42:19.565Z","dependency_job_id":"332d5321-2233-4bfd-afe8-0a7c6d820f5f","html_url":"https://github.com/acode/cli","commit_stats":{"total_commits":346,"total_committers":17,"mean_commits":"20.352941176470587","dds":"0.32947976878612717","last_synced_commit":"f3df1fcbcebc0539242cf180f226b3b4527066e6"},"previous_names":["stdlib/lib","poly/stdlib"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acode%2Fcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acode%2Fcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acode%2Fcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acode%2Fcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acode","download_url":"https://codeload.github.com/acode/cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092659,"owners_count":22013290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","autocode","aws-lambda","faas","node","nodejs","registry","sdks","serverless","stdlib"],"created_at":"2024-07-31T02:01:05.890Z","updated_at":"2025-05-14T07:08:17.689Z","avatar_url":"https://github.com/acode.png","language":"JavaScript","readme":"# \u003cimg src=\"https://content.public.files.stdlib.com/shared/static/branding/autocode-logo-wordmark.svg\" width=\"300\"\u003e\n\n**Autocode Setup** |\n[Node](https://github.com/acode/lib-node) |\n[Web](https://github.com/acode/lib-js) |\n[Python (alpha)](https://github.com/acode/lib-python) |\n[Ruby (alpha)](https://github.com/acode/lib-ruby)\n\n# Introduction\n\n[Autocode](https://autocode.com) is a fastest and easy way to build web\nservices and APIs that respond to external SaaS events. The Autocode ecosystem\ntreats external SaaS APIs as single-line function calls with the use of the\n[lib](https://github.com/acode/lib-node) package in NPM. The Autocode CLI allows\nyou to interact seamlessly with the following components of Autocode:\n\n1. Executing APIs on the Autocode standard library\n2. Uploading new APIs / web services to Autocode's hosting platform\n\nAutocode is based on Function as a Service (\"serverless\") architecture,\ninitially popularized by AWS Lambda. You can use Autocode to build modular, scalable APIs\nfor yourself and other developers in *minutes* without having to manage servers,\ngateways, domains, write documentation, or build SDKs. Your development workflow\nhas never been easier - focus on writing code you love, let Autocode handle\neverything else.\n\nAutocode uses an **open specification** called\n[FunctionScript](https://github.com/acode/FunctionScript) for function definitions and\nexecution. If you run into concerns or questions as you're building from this\nguide, please reference the FunctionScript repository. :)\n\nYou can view services published by our large and growing developer community\n[on the Autocode standard library page](https://autocode.com/lib).\n\n![lib-process](https://content.public.files.stdlib.com/shared/static/images/lib-usage.gif)\n\n# Table of contents\n\n1. [Getting started](#getting-started)\n1. [Creating your first service](#creating-your-first-service)\n1. [Connecting service endpoints](#connecting-service-endpoints)\n1. [Accessing your APIs from other applications](#accessing-your-apis-from-other-applications)\n1. [Accessing your APIs over HTTP](#accessing-your-apis-over-http)\n1. [Version control and package management](#version-control-and-package-management)\n1. [Logging](#logging)\n1. [Additional functionality](#additional-functionality)\n1. [Acknowledgements](#acknowledgements)\n1. [Contact](#contact)\n\n# Getting started\n\nTo get started with Autocode, first make sure you have Node 8.x or later installed,\n[available from the official Node.js website](https://nodejs.org). Next install\nthe Autocode CLI tools with:\n\n```\n$ npm install lib.cli -g\n```\n\nAnd you're now ready to start building!\n\n# Creating your first service\n\nThe first thing you'll want to do is create a workspace. Create a new directory\nyou intend to build your services in and initialize the workspace.\n\n```\n$ mkdir autocode-workspace\n$ cd autocode-workspace\n$ lib init\n```\n\nYou'll be asked for an e-mail address to log in to the Autocode registry.\nIf you don't yet have an account, you can create one by going to https://autocode.com/.\nNote that you can skip account creation with `lib init --no-login`.\nYou'll be unable to use the registry, but it's useful for creating workspaces\nwhen you don't have internet access.\n\nNext, create your service:\n\n```\n$ lib create \u003cservice\u003e\n```\n\nYou'll be asked for a default function name, which is the entry point\ninto your service (useful if you only want a single entry point). This will automatically\ngenerate a service project scaffold in `autocode-workspace/\u003cusername\u003e/\u003cservice\u003e`.\n\nOnce created, enter the service directory:\n\n```\n$ cd your_username/your_service\n```\n\nIn this directory, you'll see something like:\n\n```\n- functions/\n  - __main__.js\n- package.json\n- env.json\n- WELCOME.md\n- README.md\n```\n\nAt this point, there's a \"hello world\" function that's been automatically\ncreated (`__main__.js`). Autocode comes paired with a simple `lib` command for\ntesting your functions locally and running them in the cloud.\nTo test your function:\n\n```shell\n$ lib .\n\"hello world\"\n```\n\nIf we examine the `functions/__main__.js` file, we see the following:\n\n```javascript\n/**\n* A basic Hello World function\n* @param {string} name Who you're saying hello to\n* @returns {string}\n*/\nmodule.exports = async (name = 'world', context) =\u003e {\n  return `hello ${name}`;\n};\n```\n\nWe can pass parameters to it using the CLI by specifying named parameters:\n\n```shell\n$ lib . --name \"dolores abernathy\"\n\"hello dolores abernathy\"\n```\n\nNote that `context` is a magic parameter (automatically populated with\n  execution details, when provided) as is `callback` (terminates execution),\n  so these **don't need to be documented** and **can not be specified as\n  parameters when executing the function**.\n\n## Pushing to the cloud\n\nTo push your function to a development environment in the cloud...\n\n```shell\n$ lib up dev\n$ lib your_username.your_service[@dev]\n\"hello world\"\n```\n\nAnd to release it (when you're ready!)\n\n```shell\n$ lib release\n$ lib your_username.your_service\n\"hello world\"\n```\n\nYou can check out your service on the web, and use it in applications using our\nfunctions gateway, `api.stdlib.com`.\n\n```\nhttps://your_username.api.stdlib.com/your_service/\n```\n\nThat's it! You haven't written a line of code yet, and you have mastery over\nbuilding a service, testing it in a development (staging) environment online,\nand releasing it for private (or public) consumption.\n\n**Note:** By default, APIs that you publish with `lib release` will have a\ndocumentation page in the Autocode public registry. You can keep your page private,\nas well as restrict execution access or add collaborators to your API,\nby modifying your API's permissions. For more information, see this [docs page](https://docs.stdlib.com/main/#/access-control/api-permissions).\n\n**Another Note:** Staging environments (like the one created with `lib up dev`)\nare *mutable* and can be replaced indefinitely. Releases (`lib release`) are\n*immutable* and can never be overwritten. However, any service can be torn down\nwith `lib down \u003cenvironment\u003e` or `lib down -r \u003cversion\u003e` (but releases\n\tcan't be replaced once removed, to prevent mistakes and / or bad actors).\n\n# Connecting service endpoints\n\nYou'll notice that you can create more than one function per service. While\nyou can structure your project however you'd like internally, it should also\nbe noted that these functions have zero-latency access to each other. You\ncan access them internally with the `lib` [package on NPM](https://github.com/stdlib/lib-node),\nwhich behaves similarly to the `lib` command for testing. Use:\n\n```\n$ npm install lib --save\n```\n\nIn your main service directory to add it, and use it like so:\n\n#### functions/add.js\n```javascript\nmodule.exports = async (a = 0, b = 0) =\u003e {\n  return a + b;\n};\n```\n\n#### functions/add_double.js\n```javascript\nconst lib = require('lib');\n\nmodule.exports = async (a = 0, b = 0, context) =\u003e {\n  let result = await lib[`${context.service.identifier}.add`]({a: a, b: b});\n  return result * 2;\n};\n```\n\nIn this case, calling `lib .add --a 1 --b 2` will return `3` and `lib .add_double --a 1 --b 2`\nwill return `6`. The `context` magic parameter is used for its\n`context.service.identifier` property, which will return the string `\"your_username.your_service[@local]\"`\nin the case of local execution, `\"your_username.your_service[@ENV]\"` when deployed to an\nenvironment or release (where `ENV` is your environment name or semver).\n\n# Accessing your APIs from other applications\n\nAs mentioned in the previous section, you can use the NPM `lib` package that's\n[available on GitHub and NPM](https://github.com/stdlib/lib-node) to access your\nAPIs from legacy Node.js applications and even the web browser. We'll\nhave more SDKs coming out in the following months.\n\nAn existing app would call a function (username.bestTrekChar with version 0.2.1):\n\n```javascript\nconst lib = require('lib');\n\nlet result;\n\ntry {\n  result = await lib.username.bestTrekChar['@0.2.1']({name: 'spock'});\n} catch (err) {\n  // handle error\n}\n\n// do something with result\n```\n\nWhich would speak to your API...\n\n```javascript\nmodule.exports = async (name = 'kirk') =\u003e {\n\n  if (name === 'kirk') {\n    return 'why, thank, you, too, kind';\n  } else if (name === 'spock') {\n    return 'i think this feeling is called \"pleased\"';\n  } else {\n    throw new Error('Only kirk and spock supported.');\n  }\n\n};\n```\n\n# Accessing your APIs over HTTP\n\nWe definitely recommend using the [lib library on NPM](https://github.com/stdlib/lib-node)\nto make API calls as specified above, but you can also make HTTPS\nrequests directly to the Autocode gateway. HTTP query parameters are mapped\nautomatically to parameters by name.\n\n```\nhttps://username.api.stdlib.com/liveService@1.12.2/?name=BATMAN\n```\n\nMaps directly to:\n\n```javascript\n/**\n* Hello World\n* @param {string} name\n* @returns {string}\n*/\nmodule.exports = async (name = 'world') =\u003e {\n  // returns \"HELLO BATMAN\" from above HTTP query\n  return `Hello ${name}`;\n};\n```\n\n# Version control and package management\n\nA quick note on version control - Autocode is *not* a replacement for normal\ngit-based workflows, it is a supplement focused around service creation and\nexecution.\n\nYou have unlimited access to any release (that hasn't been torn down)\nwith `lib download \u003cserviceIdentifier\u003e` to download and unpack the\ntarball to a working directory.\n\nTarballs (and package contents) are *closed-source*.\nNobody but you (and potentially your teammates) has access to these. It's up to\nyou whether or not you share the guts of your service with others on GitHub or NPM.\n\nAs mentioned above: releases are *immutable* and can not be overwritten (but can\n\tbe removed, just not replaced afterwards) and development / staging environments\n\tare *mutable*, you can overwrite them as much as you'd like.\n\n# Logging\n\nLogging for services is enabled by default. When running a service locally with\n`lib .` or `lib .functionname`, all logs will be output in your console. The very\nlast output (normally a JSON-compatible string) is the return value of the function.\n\nTo view remote logs (in dev or release environments), use the following syntax:\n\n```shell\n:: Lists all logs for the service\n$ lib logs username.servicename\n\n:: Lists main service endpoint logs for \"dev\" environment\n$ lib logs username.servicename[@dev]\n\n:: Lists service endpoint named \"test\" logs for \"dev\" environment\n$ lib logs username.servicename[@dev].test\n\n:: Lists all logs for \"dev\" environment\n$ lib logs username.servicename[@dev]*\n$ lib logs username.servicename[@dev].*\n```\n\nThe default log type is `stdout`, though you can specify `stderr` with\n`lib logs username.servicename -t stderr`.\n\nLimit the number of lines to show with the `-l` argument (or `--lines`).\n\n# Additional functionality\n\nAutocode comes packed with a bunch of other goodies - as we roll out updates to\nthe platform the serverless builds we're using may change. You can update\nyour service to our latest build using `lib rebuild`. If for any reason your\nservice goes down and is unrecoverable, you can fix it with this command.\n\nTo see a full list of commands available for the CLI tools, type:\n\n```\n$ lib help\n```\n\nWe've conveniently copy-and-pasted the output here for you to peruse;\n\n```\n*\n\t-b                   Execute as a Background Function\n\t-d                   Specify debug mode (prints Gateway logs locally, response logs remotely)\n\t-i                   Specify information mode (prints tar packing and execution request progress)\n\t-t                   Specify an Identity Token to use manually\n\t-x                   Unauthenticated - Execute without a token (overrides active token and -t flag)\n\t--*                  all verbose flags converted to named keyword parameters\n\n\tRuns an Autocode function, i.e. \"lib user.service[@env]\" (remote) or \"lib .\" (local)\n\ncreate [service]\n\t-n                   No login - don't require an internet connection\n\t-w                   Write over - overwrite the current directory contents\n\t--no-login           No login - don't require an internet connection\n\t--write-over         Write over - overwrite the current directory contents\n\n\tCreates a new (local) service\n\ndown [environment]\n\t-r                   Remove a release version (provide number)\n\t--release            Remove a release version (provide number)\n\n\tRemoves Autocode package from registry and cloud environment\n\ndownload [username/name OR username/name@env OR username/name@version]\n\t-w                   Write over - overwrite the target directory contents\n\t--write-over         Write over - overwrite the target directory contents\n\n\tRetrieves and extracts Autocode package\n\nendpoints:create [name] [description] [param_1] [param_2] [...] [param_n]\n\t-n                   New directory: Create as a __main__.js file, with the name representing the directory\n\t--new                New directory: Create as a __main__.js file, with the name representing the directory\n\n\tCreates a new endpoint for a service\n\nhostnames:add [source] [target]\n\tAdds a new hostname route from a source custom hostname to a target service you own.\n\tAccepts wildcards wrapped in curly braces (\"{}\") or \"*\" at the front of the hostname.\n\nhostnames:list\n\tDisplays created hostname routes from source custom hostnames to target services you own\n\nhostnames:remove\n\tRemoves a hostname route from a source custom hostname to a target service you own\n\nhttp\n\t-p                   Port (default 8170)\n\t--port               Port (default 8170)\n\n\tCreates HTTP Server for Current Service\n\ninit [environment]\n\t-f                   Force command to overwrite existing workspace\n\t-n                   No login - don't require an internet connection\n\t--force              Force command to overwrite existing workspace\n\t--no-login           No login - don't require an internet connection\n\n\tInitializes Autocode workspace\n\nlogin\n\t--email              E-mail\n\t--password           Password\n\n\tLogs in to Autocode\n\nlogout\n\t-f                   Force - clears information even if current Access Token invalid\n\t--force              Force - clears information even if current Access Token invalid\n\n\tLogs out of Autocode in this workspace\n\nlogs [service]\n\t-l                   The number of log lines you want to retrieve\n\t-t                   The log type you want to retrieve. Allowed values are \"stdout\" and \"stderr\".\n\t--lines              The number of log lines you want to retrieve\n\t--type               The log type you want to retrieve. Allowed values are \"stdout\" and \"stderr\".\n\n\tRetrieves logs for a given service\n\nrebuild [environment]\n\t-r                   Rebuild a release package\n\t--release            Rebuild a release package\n\n\tRebuilds a service (useful for registry performance updates), alias of `lib restart -b`\n\nrelease\n\tPushes release of Autocode package to registry and cloud (Alias of `lib up -r`)\n\ntokens\n\tSelects an active Identity Token for API Authentication\n\ntokens:add-to-env\n\tSets STDLIB_SECRET_TOKEN in env.json \"local\" field to the value of an existing token\n\ntokens:list\n\t-a                   All - show invalidated tokens as well\n\t-s                   Silent mode - do not display information\n\t--all                All - show invalidated tokens as well\n\t--silent             Silent mode - do not display information\n\n\tLists your remotely generated Identity Tokens (Authentication)\n\nup [environment]\n\t-f                   Force deploy\n\t-r                   Upload a release package\n\t--force              Force deploy\n\t--release            Upload a release package\n\n\tPushes Autocode package to registry and cloud environment\n\nuser\n\t-s                   \u003ckey\u003e \u003cvalue\u003e Sets a specified key-value pair\n\t--new-password       Sets a new password via a prompt\n\t--reset-password     \u003cemail\u003e Sends a password reset request for the specified e-mail address\n\t--set                \u003ckey\u003e \u003cvalue\u003e Sets a specified key-value pair\n\n\tRetrieves (and sets) current user information\n\nversion\n\tReturns currently installed version of Autocode command line tools\n```\n\n# Upgrading from previous versions\n\nIf you're running a previous version and are having issues with the CLI,\ntry cleaning up the old CLI binary links first;\n\n```\n$ rm /usr/local/bin/f\n$ rm /usr/local/bin/lib\n$ rm /usr/local/bin/stdlib\n```\n\n# That's it!\n\nYep, it's really that easy. To keep up-to-date on developments, please\nstar us here on GitHub, and sign up a user account for the registry. You\ncan read more about service hosting and keep track of official updates on\n[the official Autocode website, autocode.com](https://autocode.com).\n\n# Acknowledgements\n\nAutocode is a product of and \u0026copy; 2021 Polybit Inc.\n\nWe'd love for you to pay attention to [@AutocodeHQ](https://twitter.com/AutocodeHQ) and\nwhat we're building next! If you'd consider joining the team, [shoot us an e-mail](mailto:careers@autocode.com).\n\nYou can also follow our team on Twitter:\n\n- [@keithwhor (Keith Horwood)](https://twitter.com/keithwhor)\n- [@hacubu (Jacob Lee)](https://twitter.com/hacubu)\n- [@YusufMusleh (Yusuf Musleh)](https://twitter.com/YusufMusleh)\n- [@threesided (Scott Gamble)](https://twitter.com/threesided)\n\nIssues encouraged, PRs welcome, and we're happy to have you on board!\nEnjoy and happy building :)\n\n# Thanks\n\nSpecial thanks to the people and companies that have believed in and supported our\nvision and development over the years.\n\n- Slack [@SlackHQ](https://twitter.com/SlackHQ)\n- Stripe [@Stripe](https://twitter.com/Stripe)\n- Romain Huet [@romainhuet](https://twitter.com/romainhuet)\n- Chad Fowler [@chadfowler](https://twitter.com/chadfowler)\n- Brian LeRoux [@brianleroux](https://twitter.com/brianleroux)\n- Ahmad Nassri [@AhmadNassri](https://twitter.com/AhmadNassri)\n\n... and many more!\n","funding_links":[],"categories":["JavaScript","api","\u003ca name=\"JavaScript\"\u003e\u003c/a\u003eJavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facode%2Fcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facode%2Fcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facode%2Fcli/lists"}