A project aimed at quickly scaffolding projects with support for TypeScript, smart file handling, and template rendering.
Go to file
2024-04-14 18:16:55 +02:00
.gitea/workflows fix(core): update 2023-07-25 17:35:13 +02:00
.vscode BREAKING CHANGE(core): switch to esm 2022-06-25 03:19:16 +02:00
test fix(core): update 2023-07-25 17:35:13 +02:00
ts fix(core): update 2023-08-18 13:00:37 +02:00
.gitignore BREAKING CHANGE(core): switch to esm 2022-06-25 03:19:16 +02:00
npmextra.json update tsconfig 2024-04-14 18:16:55 +02:00
package.json update tsconfig 2024-04-14 18:16:55 +02:00
pnpm-lock.yaml fix(core): update 2023-08-18 13:00:37 +02:00
readme.hints.md update tsconfig 2024-04-14 18:16:55 +02:00
readme.md update tsconfig 2024-04-14 18:16:55 +02:00
tsconfig.json update tsconfig 2024-04-01 21:40:52 +02:00

@push.rocks/smartscaf

scaffold projects quickly

Install

To install @push.rocks/smartscaf, run the following command in your project directory:

npm install @push.rocks/smartscaf --save

Usage

Smartscaf provides a streamlined approach to quickly scaffold projects with predefined templates. It leverages modern TypeScript and ESM syntax to offer a flexible and powerful toolchain for project initialization. This guide will walk you through utilizing Smartscaf to its full potential, including setting up templates, customizing scaffolding processes, and programmatically controlling scaffolding operations.

Setting Up Your First Template

A Smartscaf template is essentially a directory with a set of files that you want to reuse across projects. It can include source code files, configuration files, and a special .smartscaf.yml file for defining template variables and dependencies.

  1. Create a Template Directory: This directory should contain all the files and folders representing your template.

  2. Define Template Variables in .smartscaf.yml: This YAML file contains metadata about your template, such as default values for variables, dependency templates to merge, and scripts to run after scaffolding. Here's a basic example:

    defaults:
      projectName: "My Awesome Project"
    dependencies:
      merge: []
    runafter:
      - "npm install"
    
  3. Utilize Handlebars Syntax for Dynamic Content: Files in your template can use the Handlebars syntax ({{variableName}}) for dynamic content that will be replaced during the scaffolding process.

Scaffolding a New Project

Once you have a template ready, you can scaffold a new project by programmatically creating and manipulating a ScafTemplate instance from Smartscaf.

  1. Import Smartscaf and Create a New Instance:

    import { ScafTemplate } from '@push.rocks/smartscaf';
    
    async function scaffoldProject() {
      const myTemplate = await ScafTemplate.createTemplateFromDir('<path-to-your-template>');
      await myTemplate.readTemplateFromDir(); // Load the template
      // Supply any additional variables or override defaults
      await myTemplate.supplyVariables({
        projectName: 'My New Project'
      });
      // Optionally, interactively ask for missing variables
      // await myTemplate.askCliForMissingVariables();
      await myTemplate.writeToDisk('<destination-path>'); // Scaffold!
    }
    
    scaffoldProject().then(() => console.log('Project scaffolded successfully!'));
    
  2. Customizing the Scaffolding Process: You can customize the scaffolding process by defining additional logic to manipulate files, directories, or template variables before writing to disk.

Advanced Features

  • Merging Templates: Smartscaf allows you to compose complex templates by specifying dependencies in the .smartscaf.yml file. This enables you to merge multiple templates into one scaffolded project.

  • Running Scripts After Scaffolding: Specify an array of shell commands in the runafter section of your .smartscaf.yml to be executed after the project is scaffolded. This is useful for running installations or initial builds.

  • Programmatic API: Smartscaf's flexible API allows for programmatically controlling every aspect of the scaffolding process, making it suitable for integrating into build tools, command line utilities, or CI/CD pipelines.

Complete Feature Set and Use Cases

The usage scenarios outlined above merely scratch the surface of what Smartscaf can do. With its comprehensive API, you can manage complex scaffolding tasks, including but not limited to:

  • Creating project templates with varying levels of complexity and customization.
  • Dynamically adjusting project structures based on user input or external parameters.
  • Integrating scaffolding steps into larger automation workflows, significantly reducing manual setup time for new projects.

In conclusion, Smartscaf empowers developers to streamline their project initialization process, ensuring consistency, reducing boilerplate, and allowing more time to be spent on development rather than setup. Its flexibility and broad feature set make it a valuable tool in a modern developer's toolkit.

For further information and a deeper dive into Smartscaf's capabilities, please refer to the official documentation and explore the source code for advanced use cases and customization options.

This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the license file within this repository.

Please note: The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

Trademarks

This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.

Company Information

Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany

For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.

By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.