fix(metadata): Removed CI configuration file .gitlab-ci.yml and updated project metadata

This commit is contained in:
Philipp Kunz 2025-01-25 00:43:31 +01:00
parent 41ac3235b8
commit 095b4f25fb
6 changed files with 172 additions and 184 deletions

View File

@ -1,128 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install stable
- npmci npm prepare
- npmci npm install
- npmci command npm run buildDocs
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

50
changelog.md Normal file
View File

@ -0,0 +1,50 @@
# Changelog
## 2025-01-25 - 3.0.4 - fix(metadata)
Removed CI configuration file .gitlab-ci.yml and updated project metadata
- Deleted the .gitlab-ci.yml file to potentially switch or update CI/CD configurations.
- Updated the `description` and `keywords` in package.json and npmextra.json for better project documentation and SEO.
## 2024-04-01 to 2024-05-29 - 3.0.3 - maintenance
Maintenance updates and minor configuration changes.
- Updated the project description.
- Updated TypeScript configuration (`tsconfig`).
- Modified `npmextra.json` file for `githost`.
## 2023-06-25 to 2023-07-10 - 3.0.3 - organization
Organizational changes and fixes in core components.
- Transitioned to a new organization scheme.
## 2023-03-06 to 2023-06-25 - 3.0.1 to 3.0.2 - fixes
Core updates and critical fixes.
- Updated core components with fixes.
## 2022-07-24 - 2.0.9 - breaking change
Significant shifts in module support.
- **BREAKING CHANGE**: Switched to ECMAScript Module (ESM) format.
## 2018-08-27 - 1.0.16 - breaking change
Major updates in project scope.
- **BREAKING CHANGE**: Updated project scope to `@pushrocks`.
## 2017-05-26 - 1.0.15 - functionality
Enhancements in processing capabilities.
- Added post-processing functionality.
## 2017-05-12 - 1.0.13 - documentation improvements
Enhanced documentation.
- Added new documentation materials.
## 2017-05-01 - 1.0.8 - variable handling
Improvements in variable utilization.
- Introduced extended variable checking capabilities.

View File

@ -9,7 +9,7 @@
"githost": "code.foss.global", "githost": "code.foss.global",
"gitscope": "push.rocks", "gitscope": "push.rocks",
"gitrepo": "smarthbs", "gitrepo": "smarthbs",
"description": "A library that enhances handlebars with better file system support, templates compilation, and partials registration.", "description": "Enhances Handlebars with advanced filesystem support, template compilation, and efficient management of partials and variables.",
"npmPackagename": "@push.rocks/smarthbs", "npmPackagename": "@push.rocks/smarthbs",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@ -18,10 +18,13 @@
"file system", "file system",
"partials", "partials",
"template compilation", "template compilation",
"smarthbs",
"smartfile integration", "smartfile integration",
"template variables analysis", "template variables analysis",
"dynamic content",
"code generation", "code generation",
"dynamic content" "typescript",
"project management"
] ]
} }
}, },

View File

@ -2,7 +2,7 @@
"name": "@push.rocks/smarthbs", "name": "@push.rocks/smarthbs",
"version": "3.0.3", "version": "3.0.3",
"private": false, "private": false,
"description": "A library that enhances handlebars with better file system support, templates compilation, and partials registration.", "description": "Enhances Handlebars with advanced filesystem support, template compilation, and efficient management of partials and variables.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module", "type": "module",
@ -20,10 +20,13 @@
"file system", "file system",
"partials", "partials",
"template compilation", "template compilation",
"smarthbs",
"smartfile integration", "smartfile integration",
"template variables analysis", "template variables analysis",
"dynamic content",
"code generation", "code generation",
"dynamic content" "typescript",
"project management"
], ],
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",

156
readme.md
View File

@ -1,112 +1,172 @@
# @push.rocks/smarthbs # @push.rocks/smarthbs
handlebars with better fs support
A library that enhances handlebars with better file system support, templates compilation, and partials registration.
## Install ## Install
To install `@push.rocks/smarthbs`, run the following command in your terminal: To install `@push.rocks/smarthbs`, run the following command in your terminal:
```bash ```bash
npm install @push.rocks/smarthbs --save npm install @push.rocks/smarthbs --save
``` ```
This will add `@push.rocks/smarthbs` to your project's dependencies. This will add `@push.rocks/smarthbs` as a dependency to your project, allowing you to leverage its enhanced Handlebars templating capabilities.
## Usage ## Usage
The `@push.rocks/smarthbs` package enhances Handlebars with improved filesystem support, making it easy to manage partials and compile directories with template files. Below is a comprehensive guide to utilizing its capabilities in your project. The `@push.rocks/smarthbs` library extends Handlebars functionality by introducing better file system interaction, template compilation, and an easier way to manage partials. The following sections walk you through the various features and how you can utilize them for creating dynamic and organized templates.
### Getting Started ### Getting Started
First, ensure you've imported `@push.rocks/smarthbs` using ECMAScript Module (ESM) syntax in TypeScript: First, import the `@push.rocks/smarthbs` module using ECMAScript Module (ESM) syntax in a TypeScript file:
```typescript ```typescript
import * as smarthbs from '@push.rocks/smarthbs'; import * as smarthbs from '@push.rocks/smarthbs';
``` ```
### Registering Partials ### Managing Partials
In Handlebars, *partials* are reusable templates that can be included within other templates. `@push.rocks/smarthbs` simplifies the process of registering all partials from a directory, enabling a more organized template structure. Handlebars' partials allow for embedding templates within other templates, making it simple to manage reusable pieces of template code. With `@push.rocks/smarthbs`, you can efficiently register an entire directory of partials.
To register all `.hbs` files from a directory (and its subdirectories) as partials: #### Registering a Directory of Partials
To register all `.hbs` files in a directory, including those in subdirectories, as partials:
```typescript ```typescript
await smarthbs.registerPartialDir(pathToPartialsDirectory); await smarthbs.registerPartialDir('./path/to/partials');
``` ```
**Example:** Each `.hbs` file in the specified directory becomes available as a partial. Partials are identified by their paths relative to the specified directory.
```typescript
await smarthbs.registerPartialDir('./views/partials');
```
This automatically registers each `.hbs` file in the directory as a partial that can be referenced by its path relative to the specified directory.
### Compiling Templates ### Compiling Templates
`@push.rocks/smarthbs` allows you to compile an entire directory of Handlebars template files, outputting the rendered HTML to a specified directory. You can also provide a `.json` file containing data to be used by all templates during compilation. Compiling directories of Handlebars templates is seamless with `@push.rocks/smarthbs`. This feature reads templates from a source directory, compiles them using a specified data context, and writes the rendered output to a destination directory.
**Example:** #### Compile a Directory
```typescript ```typescript
await smarthbs.compileDirectory(sourceDirectory, destinationDirectory, 'data.json'); await smarthbs.compileDirectory('./source/templates', './destination/html', 'data.json');
``` ```
This reads all `.hbs` files in `sourceDirectory`, compiles them using the data from `data.json`, and writes the resulting HTML to `destinationDirectory`. Here, every `.hbs` file in `./source/templates` is compiled with data from `data.json`. The rendered outputs are saved as `.html` files in `./destination/html`.
### Finding Variables in Templates ### Working with Variables
When working with complex templates, it might be useful to programmatically find all variables used within a template: When handling complex templates, you might want to analyze which variables are used, verify their satisfaction, and ensure data completeness.
#### Finding Variables in Templates
To extract all variables used within a Handlebars template string:
```typescript ```typescript
let varsInTemplate = await smarthbs.findVarsInHbsString(templateString); const templateVariables = await smarthbs.findVarsInHbsString("Your template {{example}} here.");
console.log(varsInTemplate); // Outputs an array of variable names used in the template console.log(templateVariables); // Outputs an array of variable names: ['example']
``` ```
### Checking Variables Satisfaction #### Ensuring Variables Satisfaction
To ensure that the data provided to a template includes all necessary variables, you can compare a template against a data object: To check if a given data object satisfies all required variables in a template:
```typescript ```typescript
let missingVars = await smarthbs.checkVarsSatisfaction(templateString, dataObject); const missingVars = await smarthbs.checkVarsSatisfaction("Your template {{example}} here.", { anotherVar: "some value" });
if(missingVars.length > 0) { if(missingVars.length) {
console.error('Some required variables are missing:', missingVars); console.error('Missing variables:', missingVars);
} }
``` ```
This function returns an array of missing variable names, allowing you to validate data completeness before rendering. This function ensures the provided data object contains all variables used in the template. Otherwise, it returns an array with the names of the missing variables.
### Templates and Strings ### Rendering Templates
You can also get templates directly from strings or files on disk, which can then be rendered with context data: You can use `@push.rocks/smarthbs` to compile Handlebars templates directly from strings or files:
#### From a String
```typescript ```typescript
// From a string const stringTemplate = await smarthbs.getTemplateForString("Hello, {{name}}!");
let templateFromString = await smarthbs.getTemplateForString("Hello {{name}}!"); const renderedString = stringTemplate({ name: "World" });
let resultString = templateFromString({ name: "World" }); console.log(renderedString); // "Hello, World!"
console.log(resultString); // Outputs: Hello World!
// From a file
let templateFromFile = await smarthbs.getTemplateForFile("./templates/greeting.hbs");
let resultFileString = templateFromFile({ name: "File World" });
console.log(resultFileString); // Outputs the rendered content of greeting.hbs with provided data
``` ```
### Post-processing: Safe Syntax #### From a File
In scenarios where Handlebars syntax needs to be preserved during an intermediate step:
```typescript ```typescript
let safeString = await smarthbs.postprocess(yourTemplateString); const fileTemplate = await smarthbs.getTemplateForFile('./path/to/template.hbs');
const renderedFileString = fileTemplate({ key: "value" });
console.log(renderedFileString); // Outputs the processed template with provided data
``` ```
This method converts safe syntax markers (e.g., `{-{` and `}-}`) back into standard Handlebars syntax (`{{` and `}}`), useful if your templates go through multiple processing steps. ### Ensuring Safe Syntax
### Advanced Usage and Helpers If your Handlebars templates go through multiple processing stages, you might need to protect and restore the syntax:
`@push.rocks/smarthbs` also supports advanced use cases and custom helpers. For example, registering a helper to log all available partials or to perform runtime template compilation based on dynamic data. ```typescript
const processedString = await smarthbs.postprocess("This is {-{safe}-} syntax.");
console.log(processedString); // Restores to "This is {{safe}} syntax."
```
This approach allows you to keep placeholders intact during various stages, converting `{-{ ... }-}` syntax back to `{{ ... }}`.
### Advanced Features and Helpers
#### Custom Helpers
Extend Handlebars with custom helpers to introduce new functionalities or debug existing templates. For instance:
- **Analyze Helper**: Displays partials and their details.
- **Log Registered Partials**: Logs all registered partials, aiding in debugging.
- **Runtime Compilation**: Compile templates dynamically using the `__compile` helper.
### Example: Building an HTML Page
Suppose you are building a simple HTML page. First, define a partial for the header and a general layout:
Create a new header partial:
```hbs
<!-- ./partials/header.hbs -->
<header>
<h1>{{title}}</h1>
</header>
```
Define a base layout that includes the header and a body:
```hbs
<!-- ./layouts/main.hbs -->
{{> header title=pageTitle}}
<section>
<h2>{{subtitle}}</h2>
<p>{{content}}</p>
</section>
```
In your script, register partials and compile the layout:
```typescript
import * as smarthbs from '@push.rocks/smarthbs';
// Register partials
await smarthbs.registerPartialDir('./partials');
// Prepare data for compilation
const data = {
pageTitle: "My Awesome Page",
subtitle: "Welcome to the world of dynamic templates!",
content: "Handlebars makes creating reusable templates easy."
};
// Compile and render the layout
const mainTemplate = await smarthbs.getTemplateForFile('./layouts/main.hbs');
const renderedHtml = mainTemplate(data);
console.log(renderedHtml);
// Outputs the full HTML replacing variables in the layout with data
```
### Conclusion ### Conclusion
`@push.rocks/smarthbs` provides a robust set of features to enhance your Handlebars templating, making it easier to manage and render complex templates with external data sources and organized partials. Whether you're building web applications, generating email templates, or any task involving templating, `@push.rocks/smarthbs` can simplify and streamline your workflow. The `@push.rocks/smarthbs` library enhances the already powerful Handlebars templating engine with capabilities that are crucial for modern development workflows, especially those involving complex template management and dynamic content generation. Whether managing large-scale projects with numerous reusable components or simply wanting a better way to handle templates and partials, this tool provides a robust solution to enhance your projects and improve productivity.
## License and Legal Information ## License and Legal Information

View File

@ -1,8 +1,8 @@
/** /**
* autocreated commitinfo by @pushrocks/commitinfo * autocreated commitinfo by @push.rocks/commitinfo
*/ */
export const commitinfo = { export const commitinfo = {
name: '@pushrocks/smarthbs', name: '@push.rocks/smarthbs',
version: '3.0.3', version: '3.0.4',
description: 'handlebars with better fs support' description: 'Enhances Handlebars with advanced filesystem support, template compilation, and efficient management of partials and variables.'
} }