Skip to content

Commit

Permalink
refactor(pv-stylemark): replaced stylemark with own impl
Browse files Browse the repository at this point in the history
Removed 3rd party dependency stylemark with own imlementation and removed gulp build-wrappers

BREAKING CHANGE: With removing stylemark the seperate lsg-assets folder is not needed anymore. If
you want to use assets in your LSG you have to copy them seperatly, pv-scripts users can just use
the resources folder in most cases. Also the minimal required node-version has changed to node 18.
  • Loading branch information
friewerts committed Feb 20, 2024
1 parent 9b65502 commit 2ae386d
Show file tree
Hide file tree
Showing 49 changed files with 8,352 additions and 11,919 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
**/lib/**
**/test-pack/**
**/minimal-test/**
**/pv-stylemark/**
packages/vscode-pv-handlebars-language-server/client/out/**
packages/vscode-pv-handlebars-language-server/server/out/**
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"extends": ["pv", "prettier"],
"extends": ["prettier"],
"plugins": ["prettier"],
"parser": "babel-eslint",
"env": {
"node": true,
"browser": true
},
"ignorePatterns": ["**/*.ts"],
"rules": {
"global-require": 0,
"no-console": "off",
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.15.0
v18.19.0
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"publish": "lerna publish --conventional-commits -m \"chore(root): Publish packages\"",
"publish:canary": "lerna publish --force-publish --canary",
"test": "lerna run test",
"build": "lerna run build",
"bootstrap": "lerna bootstrap",
"add": "lerna add @pro-vision/pv-scripts --scope=",
"lint": " eslint packages",
Expand Down Expand Up @@ -36,7 +37,7 @@
}
},
"lint-staged": {
"*.ts": [
"*.js": [
"lint"
]
},
Expand Down
8 changes: 8 additions & 0 deletions packages/pv-stylemark/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
semi: true,
trailingComma: "all",
printWidth: 120,
tabWidth: 2,
endOfLine: "auto",
arrowParens: "avoid",
};
2 changes: 0 additions & 2 deletions packages/pv-stylemark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ Basic Configuration for both, cli and webpack-plugin, can be done in a `pv.confi
| componentsSrc | string | 'src/components/' | defines homefolder of components (glob: `[componentsSrc]**/*.hbs`) |
| cdPagesSrc | string | 'src/pages/' | defines homefolder of clickdummy-pages (glob: `[cdPagesSrc]**/*.hbs`) |
| hbsHelperSrc | string | 'helpers/handlebarsHelper/' | defines homefolder of additional handlebars-helpers (glob: `[hbsHelperSrc]*.js`) |
| lsgAssetsSrc | string | 'src/assets/' | defines homefolder of dummy assets used in lsg and clickdummy (glob: `[lsgAssetsSrc]**/*.js`) |
| lsgIndex | string | 'src/styleguide/index.html' | defines path to styleguide landing page html file |
| lsgConfigPath | string | 'config/config.stylemark.yaml' | defines path to lsg config file (which is required) |

Expand All @@ -65,7 +64,6 @@ module.exports = {
lsgTemplatesSrc: 'src/lsg/templates/',
cdPagesSrc: 'src/clickdummy/pages/',
hbsHelperSrc: 'helper/handlebarsHelper/',
lsgAssetsSrc: 'src/lsg/assets/',
lsgConfigPath: 'config.stylemark.yaml',
};
```
1 change: 0 additions & 1 deletion packages/pv-stylemark/config/default.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const defaultConfig = {
componentsSrc: "src/components/",
cdPagesSrc: "src/pages/",
hbsHelperSrc: "helpers/handlebarsHelper/",
lsgAssetsSrc: "src/assets/",
lsgIndex: "src/styleguide/index.html",
lsgConfigPath: "config/config.stylemark.yaml",
resourcesSrc: "resources",
Expand Down

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions packages/pv-stylemark/gulp-tasks/lsg_tasks/buildStylemark.js

This file was deleted.

25 changes: 0 additions & 25 deletions packages/pv-stylemark/gulp-tasks/lsg_tasks/copyStyleguideFiles.js

This file was deleted.

22 changes: 22 additions & 0 deletions packages/pv-stylemark/helper/config-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { readFile } = require("fs-extra");
const yaml = require("js-yaml");

const { resolveApp, getAppConfig } = require("./paths");

const getLsgConfig = async () => {
const { lsgConfigPath } = getAppConfig();
try {
const rawConfig = await readFile(resolveApp(lsgConfigPath), {
encoding: "utf-8",
});
const config = yaml.load(rawConfig);
return config ?? {};
} catch (error) {
console.warn("Error reading stylemark-config-file:", error);
return {};
}
};

module.exports = {
getLsgConfig,
};
23 changes: 23 additions & 0 deletions packages/pv-stylemark/helper/io-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { ensureDir, writeFile: fsWriteFile, watchFile } = require("fs-extra");
const { glob } = require("glob");
const { resolve, normalize } = require("path");

const writeFile = async (target, reldir, filename, markup) => {
await ensureDir(`${target}/${reldir}`);
return await fsWriteFile(`${target}/${reldir}/${filename}.html`, markup, {
encoding: "utf8",
});
};

const watchGlob = async (curGlob, callback) => {
const paths = await glob(curGlob);
const normalizedPaths = paths.map(filePath => normalize(resolve(process.cwd(), filePath)));
normalizedPaths.forEach(path => {
watchFile(path, () => callback());
});
};

module.exports = {
writeFile,
watchGlob,
};
2 changes: 1 addition & 1 deletion packages/pv-stylemark/helper/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const slash = require("slash");
const { defaultConfig } = require("../config/default.config");

const appDirectory = realpathSync(process.cwd());
const resolveApp = (relativePath) => {
const resolveApp = relativePath => {
return resolve(appDirectory, relativePath);
};

Expand Down
Loading

0 comments on commit 2ae386d

Please sign in to comment.