fix(ScafTemplate): Use interactive shell for post-scaffold scripts; update CI workflows and package metadata

This commit is contained in:
2025-08-17 15:56:11 +00:00
parent b2ba770b78
commit abc7cbc5ea
21 changed files with 187 additions and 77 deletions

View File

@@ -1,7 +1,9 @@
# @push.rocks/smartscaf
scaffold projects quickly
## Install
To install `@push.rocks/smartscaf`, run the following command in your project directory:
```bash
@@ -10,7 +12,7 @@ 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.
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
@@ -20,14 +22,14 @@ A Smartscaf template is essentially a directory with a set of files that you wan
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:
```yml
defaults:
projectName: "My Awesome Project"
dependencies:
merge: []
runafter:
- "npm install"
```
```yml
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.
@@ -37,30 +39,33 @@ Once you have a template ready, you can scaffold a new project by programmatical
1. **Import Smartscaf and Create a New Instance**:
```typescript
import { ScafTemplate } from '@push.rocks/smartscaf';
```typescript
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!
}
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!'));
```
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.
@@ -79,7 +84,7 @@ For further information and a deeper dive into Smartscaf's capabilities, please
## License and Legal Information
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](license) file within this repository.
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](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.