Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/pro-vision/fe-tools into…
Browse files Browse the repository at this point in the history
… feature/webpack-update

# Conflicts:
#	packages/pv-scripts/package-lock.json
#	packages/pv-scripts/package.json
  • Loading branch information
mbehzad committed Apr 16, 2024
2 parents e7b68c8 + 2085297 commit 02fd2b3
Show file tree
Hide file tree
Showing 89 changed files with 32,863 additions and 20,843 deletions.
1 change: 1 addition & 0 deletions .eslintignore
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
@@ -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
@@ -1 +1 @@
v16.15.0
v18.19.0
5 changes: 3 additions & 2 deletions package.json
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,8 +37,8 @@
}
},
"lint-staged": {
"*.ts": [
"lint"
"*.js": [
"npm run lint"
]
},
"config": {
Expand Down
11 changes: 11 additions & 0 deletions packages/assemble-lite/CHANGELOG.md
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.0.9](https://github.com/pro-vision/fe-tools/compare/@pro-vision/assemble-lite@2.0.8...@pro-vision/assemble-lite@2.0.9) (2023-06-12)


### Bug Fixes

* **assemble-lite:** fix order of data loads being dependent on the file read race condition ([a3f54dc](https://github.com/pro-vision/fe-tools/commit/a3f54dc0c3be3e3d09caba88c5497dbcdd0b687b))





## [2.0.8](https://github.com/pro-vision/fe-tools/compare/@pro-vision/assemble-lite@2.0.7...@pro-vision/assemble-lite@2.0.8) (2022-05-06)

**Note:** Version bump only for package @pro-vision/assemble-lite
Expand Down
12 changes: 3 additions & 9 deletions packages/assemble-lite/helper/io-helper.js
Expand Up @@ -30,17 +30,11 @@ const getPaths = async (globPattern) => {
curPatterns = [globPattern];
}

let paths = [];

await Promise.all(
curPatterns.map(async (pattern) => {
const curPaths = await asyncGlob(pattern);
paths = paths.concat(curPaths);
return curPaths;
})
const paths = await Promise.all(
curPatterns.map((pattern) => asyncGlob(pattern))
);

return paths;
return paths.flat();
};

const asyncReadFile = (filePath) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/assemble-lite/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/assemble-lite/package.json
@@ -1,6 +1,6 @@
{
"name": "@pro-vision/assemble-lite",
"version": "2.0.8",
"version": "2.0.9",
"description": "Minimal Tool to render Handlebars-Files via Node",
"author": "Frederik Riewerts <frederik.riewerts@gmail.com>",
"homepage": "https://github.com/pro-vision/fe-tools#readme",
Expand Down
8 changes: 8 additions & 0 deletions packages/custom-elements-data-extractor/CHANGELOG.md
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.2.4](https://github.com/pro-vision/fe-tools/compare/@pro-vision/custom-elements-data-extractor@0.2.3...@pro-vision/custom-elements-data-extractor@0.2.4) (2023-04-14)

**Note:** Version bump only for package @pro-vision/custom-elements-data-extractor





## [0.2.3](https://github.com/pro-vision/fe-tools/compare/@pro-vision/custom-elements-data-extractor@0.2.2...@pro-vision/custom-elements-data-extractor@0.2.3) (2022-05-06)

**Note:** Version bump only for package @pro-vision/custom-elements-data-extractor
Expand Down
11 changes: 10 additions & 1 deletion packages/custom-elements-data-extractor/README.md
Expand Up @@ -2,12 +2,21 @@

Tooling to extract data regarding the properties / attributes of custom elements. And generate custom data for [VSCode auto compilation](https://github.com/microsoft/vscode-html-languageservice/blob/main/docs/customData.md) for custom html tags.

## Install

```cmd
npm install --save-dev @pro-vision/custom-elements-data-extractor
```

## Usage

Install module as local or global dependency and call as npm script or in the command line with:

```cmd
```sh
pv-custom-data --components "src/components/**/*.ts" --iconsDir "resources/icons/" --outDir "data/"

# or if you want to try it without installing it
npx @pro-vision/custom-elements-data-extractor --components "src/components/**/*.ts" --iconsDir "resources/icons/" --outDir "data/"
```

```js
Expand Down
2 changes: 1 addition & 1 deletion packages/custom-elements-data-extractor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/custom-elements-data-extractor/package.json
@@ -1,6 +1,6 @@
{
"name": "@pro-vision/custom-elements-data-extractor",
"version": "0.2.3",
"version": "0.2.4",
"description": "Tooling to extract attributes data used in custom elements and generate HTML custom data to be used by vscode",
"main": "index.js",
"repository": {
Expand Down
25 changes: 25 additions & 0 deletions packages/pv-create-component/CHANGELOG.md
Expand Up @@ -3,6 +3,31 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.2.0](https://github.com/pro-vision/fe-tools/compare/@pro-vision/pv-create-component@0.1.2...@pro-vision/pv-create-component@0.2.0) (2023-04-14)


### Features

* **pv-create-component:** allow pv-create-component to be configured ([395d2c1](https://github.com/pro-vision/fe-tools/commit/395d2c106b92943a8f59ba2acab2894c642b3fea))


### BREAKING CHANGES

* **pv-create-component:** the node api has slightly changed, also the "unitType" property from templates
argument is renamed to "unit"





## [0.1.2](https://github.com/pro-vision/fe-tools/compare/@pro-vision/pv-create-component@0.1.1...@pro-vision/pv-create-component@0.1.2) (2022-05-13)

**Note:** Version bump only for package @pro-vision/pv-create-component





## [0.1.1](https://github.com/pro-vision/fe-tools/compare/@pro-vision/pv-create-component@0.1.0...@pro-vision/pv-create-component@0.1.1) (2022-05-06)

**Note:** Version bump only for package @pro-vision/pv-create-component
Expand Down
76 changes: 70 additions & 6 deletions packages/pv-create-component/README.md
Expand Up @@ -15,7 +15,7 @@ The Folder structure and File naming is opinionated and based on current p!v pro
## Install

```bash
npm install --global pv-create-component
npm install --save-dev @pro-vision/pv-create-component
```

## Usage
Expand All @@ -28,7 +28,7 @@ pv-create-component --skip galen --verbose

## Custom Templates

You can also provide custom templates for these files or for some of them, with the boilerplate most suitable for you project (e.g. grid system, common util imports, etc.). These files should be put inside `scripts/create-component/templates` folder and named similar to the default templates (see [lib/templates](https://github.com/pro-vision/fe-tools/tree/master/packages/pv-create-component/lib/templates)).
You can also provide custom templates for these files or for some of them, with the boilerplate most suitable for your project (e.g. grid system, common util imports, etc.). These files should be put inside `scripts/create-component/templates` folder and named similar to the default templates (see [lib/templates](https://github.com/pro-vision/fe-tools/tree/master/packages/pv-create-component/lib/templates)).

Each template should expose a function as it's default export which invoked by an object with the parameters from the cli enquiry response, should return the content of the to be generated file for the new component as a string.

Expand All @@ -47,11 +47,11 @@ These arguments will be passed to each template independent of the to be generat
| `type` |string |"Element" | one of: "Element", "Module", "Page" |
| `hasScss` |boolean | |component has .scss file |
| `hasHbs` |boolean | |component has .hbs file |
| `dataFile` |string | |handlebars data is in a yaml or json file. one of ".json", ".yaml" or `undefined` |
| `dataFile` |string \| false | |handlebars data is in a yaml or json file. one of ".json", ".yaml" or `false` |
| `hasTs` |boolean | |has a .ts file |
| `hasJs` |boolean | |has a .js file |
| `hasUnit` |boolean | |has unit test file |
| `unitType` | `"jest"`/`"karma"` | "jest" | type of unit tests |
| `unit` | `"jest"`/`"karma"` | "jest" | type of unit tests |
| `hasGalen` |boolean | |has galen test files |
| `gitAdd` |boolean | |will be staged with git |

Expand Down Expand Up @@ -104,6 +104,18 @@ example:
npx pv-create-component --name "related topics"
```

### `--namespace` (defaults to pv.config.js#namespace)

namespace used to prefix the component name

### `--config, -C` path to customized configuration

default will look under `scripts/create-component/config.js`

### `--templatesDir` path to the directory containing customized boilerplate templates

default will look under `scripts/create-component/templates`

### `--help` or `-h`

Prints all CLI options with their descriptions.
Expand All @@ -120,12 +132,58 @@ Project namespace to be used as a prefix for the component name.

Generate TypeScript files instead of Javascript files.

## Customize Configuration

Similar to the templates for boilerplate code, the questions asked in the CLI and the logic behind creating the files can be extended or modified.

For this create `scripts/create-component/config.js` which should have a default export of the modified configurations. (See [pv-create-component/config.js](https://github.com/pro-vision/fe-tools/tree/master/packages/pv-create-component/config.js))

```js
const config = require("@pro-vision/pv-create-component/config");

/* add additional files type */
config.push({
id: "CYPRESS", // identifier which can be used for future overrides/modifications
prompt: { // see https://github.com/SBoudrias/Inquirer.js for more options
name: "hasCypress",
when: (options) => options.hasHbs,
type: "confirm",
message: "Add Cypress test?",
default: true,
},
files: [
{
id: "CYPRESS-FILE",
when: (options) => options.hasCypress,
template: tpl, // function which will return the boilerplate code
// path of the file to be created
path: (options) =>
`src/components/${options.componentName}/specs/e2e/${options.componentName}.cy.ts`,
},
],
});


/* modify existing import placement e.g. instead of the end of index.scss */
config.find(item => item.id === "SCSS").imports[0].placeholder = options =>
options.type === "Element" ? "/* Element Import */" : "/* Module Import */";


/* allow creating components without type prefix for example for core component */
config.find(item => item.id === "TYPE").prompt.choices.push("Core Component");
// and use as `npm run new -- --namespace cmp --name title` to generate cmp-title files

module.exports = config;
```

See [pv-create-component/types.d.ts](https://github.com/pro-vision/fe-tools/tree/master/packages/pv-create-component/types.d.ts) for info regarding the options.

## Using Programmatically

You can also use the generator directly. For example in a project scaffolding script.

```javascript
const generator = require("pv-create-component");
const generator = require("@pro-vision/pv-create-component");

await generator({
namespace: "pv",
Expand All @@ -137,8 +195,14 @@ await generator({
hasTs: true,
hasJs: false,
hasUnit: false,
unitType: "karma",
unit: "karma",
hasGalen: true,
gitAdd: false,
});

// or with customized config
const config = require("@pro-vision/pv-create-component/config");
// modify config as needed

await generator(options, config);
```

0 comments on commit 02fd2b3

Please sign in to comment.