Skip to main content

A tool for assembling a repo using copy/paste

Project description

CodeStarter

CodeStarter is a tool for assembling a repo using copy/paste. Inspired by the installation of components with shadcn/ui, CodeStarter allows you to easily bring in code and alter it without having to worry about assembling internal packages.

Run

Contents

Quickstart

Installation

pip install codestarter[cli,local,pythondep]
  • cli: Install the CLI
  • local: Install the local file system extension
  • pythondep: Install the python dependency extension

Create a Config

Add a codestarter.json config to your project (we recommend the root of your project, but you can technically put it anywhere).

{
  "auto_overwrite": false, // If true, the output file will be overwritten if it already exists. If false, the system will not overwrite the existing file. This can be overridden by the auto_overwrite flag in the resource_configs. Default is Fa
  "global_variables": {
    "$new_project_name": "codestarter" // global variables can be referenced within the resource_configs. The key must start with $.
  },
  "dependency_configs": {
    "requirements_config": {
      // The key is the name of the dependency config that will be referenced in the resource_configs.
      "type": "requirements.txt", // The type of the dependency resolver.
      "output_file": "./requirements.txt" // The actual path to the file that contains the dependency
    }
  },
  "resource_configs": [
    {
      "input_path": "../old_repo/.vscode/", // path to the file or directory that will be copied. if it's a directory, the entire directory will be copied.
      "output_path": "./.vscode/", // path to the file or directory that the input will be copied to. If it's a directory, the input filenames will be used
      "replace_configs": [
        {
          "original_value": "old_repo", // the value to be replaced within the file, can reference global variables.
          "new_value": "$new_project_name" // the value to replace the original value with, can reference global variables.
        }
      ],
      "dependencies": { "requirements_config": ["pandas>=1.0", "httpx"] }, // The dependencies to be installed. The key is the name of the dependency config that will be referenced in the resource_configs.
      "auto_overwrite": false // [OPTIONAL] If true, the output file will be overwritten if it already exists. If false, the system will prompt or skip the overwrite. If not provided, the value of "auto_overwrite" at the top level will be used.
    }
  ],
  "commands": [
    {
      "command": "uv venv", // The command to run.
      "not_run_check": "[[ -d .venv ]] && exit 1 || exit 0" // The command to run to check if the command should be run. If the command returns 0, the command will be run. If the command returns any other value, the command will not be run.
    }
  ]
}

Run

Run the following command to assemble your repo. If you don't provide any options, the command assumes that there is a codestarter.json in the current directory. See codestarter --help for more options.

codestarter

Extensions

File

CodeStarter provides a file extension that allows you to read and store your files in the storage provider of your choice. Currently only local is supported. You can add other file config types by:

  1. Adding a item to the FlieClientType class.
  2. Adding a new class that inherits from FileClient. See local.py for an example.
  3. Updating _determine_file_client_from_path and get_file_client in __init__.py.

Dependency Resolvers

CodeStarter provides a dependency resolver extension that allows you to update dependencies in the dependency file of your choice. Currently only requirements_resolver (for python requirements.txt files) is supported. You can add other dependency resolvers by:

  1. Adding a item to the DependencyType class.
  2. Adding a new file with a resolver function that has the following signature def resolver(new_dependencies: list[str], dependency_file: str) -> tuple[str, int]:. See requirements_resolver.py for an example.
  3. Updating resolve_dependencies in __init__.py.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codestarter-0.0.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codestarter-0.0.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file codestarter-0.0.0.tar.gz.

File metadata

  • Download URL: codestarter-0.0.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for codestarter-0.0.0.tar.gz
Algorithm Hash digest
SHA256 c5b9b54e3dbbe9ba54d715ea8850369bb31dda6d07f752573579234a1cb5ede9
MD5 feb324f75191d3fa7129366c3c75e774
BLAKE2b-256 d062735e825bde23351f34d470c6613604f9b4ceaa46c87a94b66a27187c853b

See more details on using hashes here.

File details

Details for the file codestarter-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: codestarter-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for codestarter-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47dbd2c20679eaaa7aef59c482828f10da9e6f8da08add8634a2667424ffa08f
MD5 02b6c10025a3a2ba4d59d79e0c921e68
BLAKE2b-256 a2dbe7e96e6c1ab90ce7a396e1fb076e27d18618ea80c0948bddbef1c1605109

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page