Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
a11b4ee7df | |||
29568c88c3 | |||
5bfcb95c94 | |||
246ed4d74b | |||
aee65a5d9a | |||
b83e88eefb | |||
1821a1bdfd | |||
af10b4eee5 | |||
fdc9cb6784 | |||
8db0cac292 | |||
dad6119945 | |||
369cb0a58c | |||
67ef49ddce | |||
d6cf698327 | |||
4fe9acb0ec | |||
f8f74e32b5 | |||
471b52c78e | |||
5db9964480 | |||
fb94ff3be6 | |||
0af5016d43 | |||
e52ff07b07 | |||
b056ab998d | |||
b5f0bdc8e8 | |||
a5a69ef25e | |||
92da6611c7 | |||
9288ed3d2c |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm publish
|
||||
|
||||
metadata:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
19
.gitignore
vendored
19
.gitignore
vendored
@ -1,4 +1,19 @@
|
||||
node_modules/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
#------# custom
|
@ -1,59 +0,0 @@
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmpage
|
||||
stage: pages
|
||||
script:
|
||||
- npmci command npmpage --host gitlab
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
47
README.md
47
README.md
@ -1,36 +1,26 @@
|
||||
# smartfm
|
||||
smartfm handles frontmatter of files
|
||||
# @push.rocks/smartfm
|
||||
frontmatter done right
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/smartfm)
|
||||
[](https://gitlab.com/pushrocks/smartfm)
|
||||
[](https://github.com/pushrocks/smartfm)
|
||||
[](https://pushrocks.gitlab.io/smartfm/)
|
||||
> Please consider following us on https://beta.news/lossless to subscribe to infos on changes and updates.
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartfm)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartfm)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/smartfm)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartfm/)
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/pushrocks/smartfm/commits/master)
|
||||
[](https://gitlab.com/pushrocks/smartfm/commits/master)
|
||||
[](https://david-dm.org/pushrocks/smartfm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartfm/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartfm)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
[](https://www.npmjs.com/package/@push.rocks/smartfm)
|
||||
[](https://snyk.io/test/npm/@push.rocks/smartfm)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://prettier.io/)
|
||||
|
||||
## Usage
|
||||
|
||||
say you have the following markdown file:
|
||||
```markdown
|
||||
---
|
||||
title: A really awesome article
|
||||
date: 23-10-2020
|
||||
type: feature
|
||||
---
|
||||
# A Awesome Title
|
||||
The world is cool. And here is why
|
||||
* reason 1
|
||||
* reason 2
|
||||
```
|
||||
We recommend TypeScript for best in class Intellisense.
|
||||
|
||||
```javascript
|
||||
import * as smartfm from * smartfm
|
||||
@ -65,4 +55,9 @@ let mySmartfm = new smartfm.Smartfm({
|
||||
})
|
||||
```
|
||||
|
||||
[](https://push.rocks)
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
|
46
changelog.md
Normal file
46
changelog.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-01-23 - 2.1.0 - feat(ci)
|
||||
Introduce new CI workflows for Gitea and remove GitLab CI
|
||||
|
||||
- Added .gitea/workflows/default_nottags.yaml and .gitea/workflows/default_tags.yaml for Gitea CI workflow.
|
||||
- Removed .gitlab-ci.yml indicating a shift from GitLab CI to Gitea CI.
|
||||
- Updated package.json to use updated repository URLs conforming to the new hosting strategy.
|
||||
- Updated README.md and npmextra.json with new npm package name and repository details.
|
||||
|
||||
## 2024-04-01 - 2.0.4 - Maintenance
|
||||
Switch to a new organizational scheme and multiple updates to `npmextra.json`.
|
||||
|
||||
- Updated `npmextra.json` multiple times for consistency with `githost`.
|
||||
- Switched to a new organization scheme.
|
||||
|
||||
## 2019-09-04 - 2.0.1 to 2.0.4 - Core Updates
|
||||
Continual core updates to enhance stability.
|
||||
|
||||
- Core updates implemented in versions 2.0.1, 2.0.2, and 2.0.3.
|
||||
|
||||
## 2018-08-27 - 2.0.0 - Dependencies
|
||||
Significant updates in dependencies management.
|
||||
|
||||
- Removed obsolete import of `typings-global`.
|
||||
- Introduction of the 2.x series with dependency fixes.
|
||||
|
||||
## 2018-08-27 - 1.0.5 - BREAKING CHANGE
|
||||
Transition to a new organizational scope.
|
||||
|
||||
- Switched to `@pushrocks` scope, marking a major change in project organization.
|
||||
|
||||
## 2017-05-27 - 1.0.3 - 1.0.4 - Configuration Updates
|
||||
Enhancements in configuration and standards.
|
||||
|
||||
- Added `npmextra.json`.
|
||||
- Updated CI YAML file.
|
||||
- Adopted latest project standards.
|
||||
|
||||
## 2016-11-14 - 1.0.0 to 1.0.2 - Initial Release & Improvements
|
||||
Initial project release with subsequent improvements.
|
||||
|
||||
- Initial working release.
|
||||
- Improved Readme for better user guidance.
|
||||
- Continuous updates to align with project standards.
|
||||
|
33
dist/index.d.ts
vendored
33
dist/index.d.ts
vendored
@ -1,33 +0,0 @@
|
||||
import 'typings-global';
|
||||
export declare type TFrontMatter = 'yaml' | 'json';
|
||||
export interface IParsedFM {
|
||||
data: any;
|
||||
content: string;
|
||||
orig: string;
|
||||
}
|
||||
export interface ISmartfmContructorOptions {
|
||||
fmType: TFrontMatter;
|
||||
}
|
||||
/**
|
||||
* class smartfm handles frontmatter
|
||||
*/
|
||||
export declare class Smartfm {
|
||||
fmType: TFrontMatter;
|
||||
constructor(optionsArg: ISmartfmContructorOptions);
|
||||
/**
|
||||
* add frontmatter to a string
|
||||
*/
|
||||
stringify(bodyString: string, frontmatterData: any): any;
|
||||
/**
|
||||
* parse a string that has frontmatter attached, YAML notation
|
||||
*/
|
||||
parse(stringToParse: string): IParsedFM;
|
||||
}
|
||||
/**
|
||||
* parse a string that has frontmatter attached, YAML notation
|
||||
*/
|
||||
export declare let parse: (stringToParse: string) => IParsedFM;
|
||||
/**
|
||||
* add frontmatter to a string
|
||||
*/
|
||||
export declare let stringify: (bodyString: string, frontmatterData: any) => any;
|
37
dist/index.js
vendored
37
dist/index.js
vendored
@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
let grayMatter = require('gray-matter');
|
||||
/**
|
||||
* class smartfm handles frontmatter
|
||||
*/
|
||||
class Smartfm {
|
||||
constructor(optionsArg) {
|
||||
this.fmType = optionsArg.fmType;
|
||||
}
|
||||
/**
|
||||
* add frontmatter to a string
|
||||
*/
|
||||
stringify(bodyString, frontmatterData) {
|
||||
return exports.stringify(bodyString, frontmatterData);
|
||||
}
|
||||
/**
|
||||
* parse a string that has frontmatter attached, YAML notation
|
||||
*/
|
||||
parse(stringToParse) {
|
||||
return exports.parse(stringToParse);
|
||||
}
|
||||
}
|
||||
exports.Smartfm = Smartfm;
|
||||
/**
|
||||
* parse a string that has frontmatter attached, YAML notation
|
||||
*/
|
||||
exports.parse = (stringToParse) => {
|
||||
return grayMatter(stringToParse);
|
||||
};
|
||||
/**
|
||||
* add frontmatter to a string
|
||||
*/
|
||||
exports.stringify = (bodyString, frontmatterData) => {
|
||||
return grayMatter.stringify(bodyString, frontmatterData);
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLElBQUksVUFBVSxHQUFHLE9BQU8sQ0FBQyxhQUFhLENBQUMsQ0FBQTtBQWN2Qzs7R0FFRztBQUNIO0lBR0ksWUFBWSxVQUFxQztRQUM3QyxJQUFJLENBQUMsTUFBTSxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUE7SUFDbkMsQ0FBQztJQUVEOztPQUVHO0lBQ0gsU0FBUyxDQUFDLFVBQWtCLEVBQUUsZUFBb0I7UUFDOUMsTUFBTSxDQUFDLGlCQUFTLENBQUMsVUFBVSxFQUFFLGVBQWUsQ0FBQyxDQUFBO0lBQ2pELENBQUM7SUFFRDs7T0FFRztJQUNILEtBQUssQ0FBQyxhQUFxQjtRQUN2QixNQUFNLENBQUMsYUFBSyxDQUFDLGFBQWEsQ0FBQyxDQUFBO0lBQy9CLENBQUM7Q0FDSjtBQXBCRCwwQkFvQkM7QUFFRDs7R0FFRztBQUNRLFFBQUEsS0FBSyxHQUFHLENBQUMsYUFBcUI7SUFDckMsTUFBTSxDQUFDLFVBQVUsQ0FBQyxhQUFhLENBQUMsQ0FBQTtBQUNwQyxDQUFDLENBQUE7QUFFRDs7R0FFRztBQUNRLFFBQUEsU0FBUyxHQUFHLENBQUMsVUFBa0IsRUFBRSxlQUFvQjtJQUM1RCxNQUFNLENBQUMsVUFBVSxDQUFDLFNBQVMsQ0FBQyxVQUFVLEVBQUUsZUFBZSxDQUFDLENBQUE7QUFDNUQsQ0FBQyxDQUFBIn0=
|
20
npmextra.json
Normal file
20
npmextra.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartfm",
|
||||
"description": "frontmatter done right",
|
||||
"npmPackagename": "@push.rocks/smartfm",
|
||||
"license": "MIT"
|
||||
}
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis 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. \n\n**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.\n\n### Trademarks\n\nThis 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.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy 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.\n"
|
||||
}
|
||||
}
|
46
package.json
46
package.json
@ -1,15 +1,20 @@
|
||||
{
|
||||
"name": "smartfm",
|
||||
"version": "1.0.1",
|
||||
"name": "@push.rocks/smartfm",
|
||||
"version": "2.1.0",
|
||||
"private": false,
|
||||
"description": "frontmatter done right",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"test": "(tstest test/)",
|
||||
"build": "tsbuild tsfolders --allowimplicitany",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/pushrocks/smartfm.git"
|
||||
"url": "git+https://code.foss.global/push.rocks/smartfm.git"
|
||||
},
|
||||
"keywords": [
|
||||
"frontmatter"
|
||||
@ -17,16 +22,29 @@
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/smartfm/issues"
|
||||
"url": "https://code.foss.global/push.rocks/smartfm/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartfm#README",
|
||||
"homepage": "https://code.foss.global/push.rocks/smartfm#readme",
|
||||
"dependencies": {
|
||||
"gray-matter": "^2.1.0",
|
||||
"typings-global": "^1.0.14"
|
||||
"gray-matter": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/should": "^8.1.30",
|
||||
"should": "^11.1.1",
|
||||
"typings-test": "^1.0.3"
|
||||
}
|
||||
"@git.zone/tsbuild": "^2.1.17",
|
||||
"@git.zone/tsrun": "^1.2.8",
|
||||
"@git.zone/tstest": "^1.0.24",
|
||||
"@push.rocks/tapbundle": "^5.5.6",
|
||||
"@types/node": "^12.7.4"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
]
|
||||
}
|
||||
|
9682
pnpm-lock.yaml
generated
Normal file
9682
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
||||
import 'typings-test';
|
25
test/test.js
25
test/test.js
@ -1,25 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-test");
|
||||
const should = require("should");
|
||||
const smartfm = require("../dist/index");
|
||||
describe('smartfm', function () {
|
||||
let testSmartfm = new smartfm.Smartfm({ fmType: 'yaml' });
|
||||
it('.parse()', function () {
|
||||
let testString = `---
|
||||
testKey: testValue
|
||||
testKey2: testValue2
|
||||
---
|
||||
# some markdown`;
|
||||
let parsedString = testSmartfm.parse(testString);
|
||||
should(parsedString.data).have.property('testKey', 'testValue');
|
||||
should(parsedString.data).have.property('testKey2', 'testValue2');
|
||||
should(parsedString.orig).equal(testString);
|
||||
});
|
||||
it('.stringify', function () {
|
||||
let testStringPure = `# some markdown heading\nsome first row`;
|
||||
let testStringCombined = testSmartfm.stringify(testStringPure, { testData: 'hi' });
|
||||
let resultString = '---\ntestData: hi\n---\n# some markdown heading\nsome first row\n';
|
||||
should(resultString).equal(testStringCombined);
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFFaEMseUNBQXdDO0FBRXhDLFFBQVEsQ0FBQyxTQUFTLEVBQUU7SUFDaEIsSUFBSSxXQUFXLEdBQUcsSUFBSSxPQUFPLENBQUMsT0FBTyxDQUFDLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxDQUFDLENBQUE7SUFDekQsRUFBRSxDQUFDLFVBQVUsRUFBRTtRQUNYLElBQUksVUFBVSxHQUFHOzs7O2dCQUlULENBQUE7UUFDUixJQUFJLFlBQVksR0FBRyxXQUFXLENBQUMsS0FBSyxDQUFDLFVBQVUsQ0FBQyxDQUFBO1FBQ2hELE1BQU0sQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxTQUFTLEVBQUUsV0FBVyxDQUFDLENBQUE7UUFDL0QsTUFBTSxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLFVBQVUsRUFBRSxZQUFZLENBQUMsQ0FBQTtRQUNqRSxNQUFNLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxDQUFDLEtBQUssQ0FBQyxVQUFVLENBQUMsQ0FBQTtJQUMvQyxDQUFDLENBQUMsQ0FBQTtJQUNGLEVBQUUsQ0FBQyxZQUFZLEVBQUU7UUFDYixJQUFJLGNBQWMsR0FBRyx5Q0FBeUMsQ0FBQTtRQUM5RCxJQUFJLGtCQUFrQixHQUFHLFdBQVcsQ0FBQyxTQUFTLENBQUMsY0FBYyxFQUFFLEVBQUUsUUFBUSxFQUFFLElBQUksRUFBRSxDQUFDLENBQUE7UUFDbEYsSUFBSSxZQUFZLEdBQUcsbUVBQW1FLENBQUE7UUFDdEYsTUFBTSxDQUFDLFlBQVksQ0FBQyxDQUFDLEtBQUssQ0FBQyxrQkFBa0IsQ0FBQyxDQUFBO0lBQ2xELENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==
|
60
test/test.ts
60
test/test.ts
@ -1,25 +1,45 @@
|
||||
import 'typings-test'
|
||||
import * as should from 'should'
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
|
||||
import * as smartfm from '../dist/index'
|
||||
import * as smartfm from '../ts/index.js';
|
||||
|
||||
describe('smartfm', function () {
|
||||
let testSmartfm = new smartfm.Smartfm({ fmType: 'yaml' })
|
||||
it('.parse()', function () {
|
||||
let testString = `---
|
||||
let testSmartfm = new smartfm.Smartfm({ fmType: 'yaml' });
|
||||
tap.test('.parse()', async () => {
|
||||
let testString = `---
|
||||
testKey: testValue
|
||||
testKey2: testValue2
|
||||
---
|
||||
# some markdown`
|
||||
let parsedString = testSmartfm.parse(testString)
|
||||
should(parsedString.data).have.property('testKey', 'testValue')
|
||||
should(parsedString.data).have.property('testKey2', 'testValue2')
|
||||
should(parsedString.orig).equal(testString)
|
||||
})
|
||||
it('.stringify', function () {
|
||||
let testStringPure = `# some markdown heading\nsome first row`
|
||||
let testStringCombined = testSmartfm.stringify(testStringPure, { testData: 'hi' })
|
||||
let resultString = '---\ntestData: hi\n---\n# some markdown heading\nsome first row\n'
|
||||
should(resultString).equal(testStringCombined)
|
||||
})
|
||||
})
|
||||
# some markdown
|
||||
`;
|
||||
let parsedString = testSmartfm.parse(testString);
|
||||
expect(parsedString.data).toHaveProperty('testKey', 'testValue');
|
||||
expect(parsedString.data).toHaveProperty('testKey2', 'testValue2');
|
||||
expect(parsedString.orig.toString()).toEqual(testString);
|
||||
});
|
||||
tap.test('should stringify data', async () => {
|
||||
let testStringPure = `# some markdown heading\nsome first row`;
|
||||
let testStringCombined = testSmartfm.stringify(testStringPure, { testData: 'hi' });
|
||||
let resultString = '---\ntestData: hi\n---\n# some markdown heading\nsome first row\n';
|
||||
expect(resultString).toEqual(testStringCombined);
|
||||
});
|
||||
|
||||
tap.test('should parse a normal frontmatter file', async () => {
|
||||
const normalFile = `---
|
||||
heythere: awesome
|
||||
---
|
||||
really
|
||||
`;
|
||||
let result = testSmartfm.parse(normalFile);
|
||||
expect(result.data.heythere).toEqual('awesome');
|
||||
});
|
||||
|
||||
tap.test('should parse a commented out frontmatter file', async () => {
|
||||
const commentedFile = `# ---
|
||||
# heythere: awesome
|
||||
# ---
|
||||
really
|
||||
`;
|
||||
let result = testSmartfm.parseFromComments('# ', commentedFile);
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartfm',
|
||||
version: '2.1.0',
|
||||
description: 'frontmatter done right'
|
||||
}
|
72
ts/index.ts
72
ts/index.ts
@ -1,53 +1,45 @@
|
||||
import 'typings-global'
|
||||
let grayMatter = require('gray-matter')
|
||||
import grayMatter from 'gray-matter';
|
||||
|
||||
export type TFrontMatter = 'yaml' | 'json'
|
||||
|
||||
export interface IParsedFM {
|
||||
data: any
|
||||
content: string
|
||||
orig: string
|
||||
}
|
||||
export type TFrontMatter = 'yaml' | 'json';
|
||||
|
||||
export interface ISmartfmContructorOptions {
|
||||
fmType: TFrontMatter
|
||||
fmType: TFrontMatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* class smartfm handles frontmatter
|
||||
*/
|
||||
export class Smartfm {
|
||||
fmType: TFrontMatter
|
||||
fmType: TFrontMatter;
|
||||
|
||||
constructor(optionsArg: ISmartfmContructorOptions) {
|
||||
this.fmType = optionsArg.fmType
|
||||
}
|
||||
constructor(optionsArg: ISmartfmContructorOptions) {
|
||||
this.fmType = optionsArg.fmType;
|
||||
}
|
||||
|
||||
/**
|
||||
* add frontmatter to a string
|
||||
*/
|
||||
stringify(bodyString: string, frontmatterData: any) {
|
||||
return stringify(bodyString, frontmatterData)
|
||||
}
|
||||
/**
|
||||
* add frontmatter to a string
|
||||
*/
|
||||
stringify(bodyString: string, frontmatterData: any) {
|
||||
return grayMatter.stringify(bodyString, frontmatterData);
|
||||
}
|
||||
|
||||
/**
|
||||
* parse a string that has frontmatter attached, YAML notation
|
||||
*/
|
||||
parse(stringToParse: string): IParsedFM {
|
||||
return parse(stringToParse)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* parse a string that has frontmatter attached, YAML notation
|
||||
*/
|
||||
export let parse = (stringToParse: string): IParsedFM => {
|
||||
return grayMatter(stringToParse)
|
||||
}
|
||||
|
||||
/**
|
||||
* add frontmatter to a string
|
||||
*/
|
||||
export let stringify = (bodyString: string, frontmatterData: any) => {
|
||||
return grayMatter.stringify(bodyString, frontmatterData)
|
||||
/**
|
||||
* parse a string that has frontmatter attached, YAML notation
|
||||
*/
|
||||
parse(stringToParse: string) {
|
||||
return grayMatter(stringToParse);
|
||||
}
|
||||
|
||||
/**
|
||||
* parse from commnets
|
||||
*/
|
||||
parseFromComments(commentStart: string, stringToParse: string) {
|
||||
const diffFunc = (diffMe, diffBy) => diffMe.split(diffBy).join('');
|
||||
let lines = stringToParse.split('\n');
|
||||
lines = lines.map((line) => {
|
||||
return diffFunc(line, commentStart);
|
||||
});
|
||||
const cleanedString = lines.join('\n');
|
||||
return this.parse(cleanedString);
|
||||
}
|
||||
}
|
||||
|
17
tsconfig.json
Normal file
17
tsconfig.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {}
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Reference in New Issue
Block a user