Skip to content

Commit 2cdd9da

Browse files
committed
Updated to extended components.
1 parent 30bd859 commit 2cdd9da

File tree

17 files changed

+524
-23
lines changed

17 files changed

+524
-23
lines changed

.eslintignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Javascript builds
2+
node_modules
3+
dist
4+
tsc_out
5+
.out
6+
.changelog
7+
.DS_Store
8+
coverage
9+
.cache
10+
.tmp
11+
.eslintcache
12+
generated
13+
14+
# package managers
15+
yarn-error.log
16+
lerna-debug.log
17+
18+
# IDEs and editors
19+
.idea
20+
.project
21+
.classpath
22+
.c9
23+
*.launch
24+
.settings
25+
*.sublime-workspace
26+
.history
27+
.vscode
28+
.yo-rc.json
29+
30+
# IDE - VSCode
31+
.vscode
32+
# For vim
33+
*.swp
34+
35+
public

.eslintrc-md.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"plugins": [
3+
"markdown",
4+
"react"
5+
],
6+
"parserOptions": {
7+
"ecmaVersion": 9,
8+
"sourceType": "module",
9+
"ecmaFeatures": {
10+
"jsx": true
11+
}
12+
},
13+
"settings": {
14+
"react": {
15+
"version": "16.4.0"
16+
}
17+
},
18+
"rules": {
19+
"eol-last": 2,
20+
"spaced-comment": 2,
21+
"no-unused-vars": 0,
22+
"no-this-before-super": 2,
23+
"react/jsx-uses-react": "error",
24+
"react/jsx-uses-vars": "error",
25+
"react/no-unknown-property": 2,
26+
"react/jsx-no-undef": 2
27+
}
28+
}

.eslintrc.json

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"node": true,
5+
"es6": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:react/recommended",
10+
"plugin:react-hooks/recommended",
11+
"plugin:@typescript-eslint/recommended",
12+
"prettier"
13+
],
14+
"overrides": [
15+
{
16+
"files": ["**/patternfly-docs/pages/*"],
17+
"rules": {
18+
"arrow-body-style": "off"
19+
}
20+
}
21+
],
22+
"parserOptions": {
23+
"ecmaVersion": "latest",
24+
"sourceType": "module",
25+
"ecmaFeatures": {
26+
"jsx": true
27+
}
28+
},
29+
"settings": {
30+
"react": {
31+
"version": "detect"
32+
}
33+
},
34+
"plugins": ["react", "react-hooks", "@typescript-eslint"],
35+
"rules": {
36+
"@typescript-eslint/adjacent-overload-signatures": "error",
37+
"@typescript-eslint/array-type": "error",
38+
"@typescript-eslint/consistent-type-assertions": "error",
39+
"@typescript-eslint/consistent-type-definitions": "error",
40+
"@typescript-eslint/no-misused-new": "error",
41+
"@typescript-eslint/no-namespace": "error",
42+
"@typescript-eslint/no-unused-vars": [
43+
"error",
44+
{
45+
"argsIgnorePattern": "^_"
46+
}
47+
],
48+
"@typescript-eslint/prefer-for-of": "error",
49+
"@typescript-eslint/prefer-function-type": "error",
50+
"@typescript-eslint/prefer-namespace-keyword": "error",
51+
"@typescript-eslint/unified-signatures": "error",
52+
"@typescript-eslint/no-var-requires": "off",
53+
"arrow-body-style": "error",
54+
"camelcase": [
55+
"error",
56+
{
57+
"ignoreDestructuring": true
58+
}
59+
],
60+
"constructor-super": "error",
61+
"curly": "error",
62+
"dot-notation": "error",
63+
"eqeqeq": ["error", "smart"],
64+
"guard-for-in": "error",
65+
"max-classes-per-file": ["error", 1],
66+
"no-nested-ternary": "error",
67+
"no-bitwise": "error",
68+
"no-caller": "error",
69+
"no-cond-assign": "error",
70+
"no-console": "error",
71+
"no-debugger": "error",
72+
"no-empty": "error",
73+
"no-eval": "error",
74+
"no-new-wrappers": "error",
75+
"no-undef-init": "error",
76+
"no-unsafe-finally": "error",
77+
"no-unused-expressions": [
78+
"error",
79+
{
80+
"allowTernary": true,
81+
"allowShortCircuit": true
82+
}
83+
],
84+
"no-unused-labels": "error",
85+
"no-var": "error",
86+
"object-shorthand": "error",
87+
"one-var": ["error", "never"],
88+
"prefer-const": "error",
89+
"radix": ["error", "as-needed"],
90+
"react/prop-types": 0,
91+
"react/display-name": 0,
92+
"react-hooks/exhaustive-deps": "warn",
93+
"react/no-unescaped-entities": ["error", { "forbid": [">", "}"] }],
94+
"spaced-comment": "error",
95+
"use-isnan": "error"
96+
}
97+
}

.prettierignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Javascript builds
2+
node_modules
3+
dist
4+
tsc_out
5+
.out
6+
.changelog
7+
.DS_Store
8+
coverage
9+
.cache
10+
.tmp
11+
.eslintcache
12+
generated
13+
14+
# package managers
15+
yarn-error.log
16+
lerna-debug.log
17+
18+
# IDEs and editors
19+
.idea
20+
.project
21+
.classpath
22+
.c9
23+
*.launch
24+
.settings
25+
*.sublime-workspace
26+
.history
27+
.vscode
28+
.yo-rc.json
29+
30+
# IDE - VSCode
31+
.vscode
32+
# For vim
33+
*.swp
34+
35+
public

.prettierrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"trailingComma": "none",
6+
"useTabs": false,
7+
"printWidth": 120
8+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# patternfly-hac-components
1+
# extended-components

fed-mini-modules.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
const fse = require('fs-extra');
2+
const glob = require('glob');
3+
const path = require('path');
4+
5+
const root = process.cwd();
6+
7+
const sourceFiles = glob
8+
.sync(`${root}/src/*/`)
9+
.map((name) => name.replace(/\/$/, ''));
10+
11+
const indexTypings = glob.sync(`${root}/src/index.d.ts`);
12+
13+
async function copyTypings(files, dest) {
14+
const cmds = [];
15+
files.forEach((file) => {
16+
const fileName = file.split('/').pop();
17+
cmds.push(fse.copyFile(file, `${dest}/${fileName}`));
18+
});
19+
return Promise.all(cmds);
20+
}
21+
22+
async function createPackage(file) {
23+
const fileName = file.split('/').pop();
24+
const esmSource = glob.sync(`${root}/esm/${fileName}/**/index.js`)[0];
25+
/**
26+
* Prevent creating package.json for directories with no JS files (like CSS directories)
27+
*/
28+
if (!esmSource) {
29+
return;
30+
}
31+
32+
const destFile = `${path.resolve(root, file.split('/src/').pop())}/package.json`;
33+
34+
const esmRelative = path.relative(file.replace('/src', ''), esmSource);
35+
const content = {
36+
main: 'index.js',
37+
module: esmRelative,
38+
};
39+
const typings = glob.sync(`${root}/src/${fileName}/*.d.ts`);
40+
let cmds = [];
41+
content.typings = 'index.d.ts';
42+
cmds.push(copyTypings(typings, `${root}/${fileName}`));
43+
cmds.push(fse.writeJSON(destFile, content));
44+
return Promise.all(cmds);
45+
}
46+
47+
async function generatePackages(files) {
48+
const cmds = files.map((file) => createPackage(file));
49+
return Promise.all(cmds);
50+
}
51+
52+
async function run(files) {
53+
try {
54+
await generatePackages(files);
55+
if (indexTypings.length === 1) {
56+
copyTypings(indexTypings, root);
57+
}
58+
} catch (error) {
59+
console.error(error);
60+
process.exit(1);
61+
}
62+
}
63+
64+
run(sourceFiles);

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@patternfly/patternfly-hac-components-root",
2+
"name": "@patternfly/extended-components-root",
33
"private": true,
44
"version": "0.0.0",
55
"description": "This library provides patternfly extensions",
@@ -8,17 +8,18 @@
88
"packages/*"
99
],
1010
"scripts": {
11-
"build": "yarn workspace @patternfly/patternfly-hac-components build",
12-
"build:docs": "yarn workspace @patternfly/patternfly-hac-components docs:build",
13-
"start": "yarn build && concurrently --kill-others \"yarn workspace @patternfly/patternfly-hac-components docs:develop\"",
14-
"serve:docs": "yarn workspace @patternfly/patternfly-hac-components docs:serve",
15-
"clean": "yarn workspace @patternfly/patternfly-hac-components clean",
11+
"build": "yarn workspace @patternfly/extended-components build",
12+
"build:docs": "yarn workspace @patternfly/extended-components docs:build",
13+
"build:fed:packages": "yarn workspace @patternfly/extended-components build:fed:packages",
14+
"start": "yarn build && concurrently --kill-others \"yarn workspace @patternfly/extended-components docs:develop\"",
15+
"serve:docs": "yarn workspace @patternfly/extended-components docs:serve",
16+
"clean": "yarn workspace @patternfly/extended-components clean",
1617
"lint:js": "node --max-old-space-size=4096 node_modules/.bin/eslint packages --ext js,jsx,ts,tsx --cache",
1718
"lint:md": "yarn eslint packages --ext md --no-eslintrc --config .eslintrc-md.json --cache",
1819
"lint": "yarn lint:js && yarn lint:md",
1920
"test": "TZ=EST jest packages",
20-
"test:a11y": "yarn workspace @patternfly/patternfly-hac-components test:a11y",
21-
"serve:a11y": "yarn workspace @patternfly/patternfly-hac-components serve:a11y"
21+
"test:a11y": "yarn workspace @patternfly/extended-components test:a11y",
22+
"serve:a11y": "yarn workspace @patternfly/extended-components serve:a11y"
2223
},
2324
"devDependencies": {
2425
"react": "^17",
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
const fse = require('fs-extra');
2+
const glob = require('glob');
3+
const path = require('path');
4+
5+
const root = process.cwd();
6+
7+
const sourceFiles = glob
8+
.sync(`${root}/src/*/`)
9+
.map((name) => name.replace(/\/$/, ''));
10+
11+
const indexTypings = glob.sync(`${root}/src/index.d.ts`);
12+
13+
async function copyTypings(files, dest) {
14+
const cmds = [];
15+
files.forEach((file) => {
16+
const fileName = file.split('/').pop();
17+
cmds.push(fse.copyFile(file, `${dest}/${fileName}`));
18+
});
19+
return Promise.all(cmds);
20+
}
21+
22+
async function createPackage(file) {
23+
const fileName = file.split('/').pop();
24+
const esmSource = glob.sync(`${root}/dist/esm/${fileName}/**/index.js`)[0];
25+
/**
26+
* Prevent creating package.json for directories with no JS files (like CSS directories)
27+
*/
28+
if (!esmSource) {
29+
return;
30+
}
31+
32+
const destFile = `${path.resolve(`${root}/dist/esm`, fileName)}/package.json`;
33+
34+
const esmRelative = path.relative(file.replace('/dist/esm', ''), esmSource);
35+
const content = {
36+
main: 'index.js',
37+
module: esmRelative,
38+
};
39+
const typings = glob.sync(`${root}/src/${fileName}/*.d.ts`);
40+
const cmds = [];
41+
content.typings = 'index.d.ts';
42+
cmds.push(copyTypings(typings, `${root}/dist/${fileName}`));
43+
cmds.push(fse.writeJSON(destFile, content));
44+
return Promise.all(cmds);
45+
}
46+
47+
async function generatePackages(files) {
48+
const cmds = files.map((file) => createPackage(file));
49+
return Promise.all(cmds);
50+
}
51+
52+
async function run(files) {
53+
try {
54+
await generatePackages(files);
55+
if (indexTypings.length === 1) {
56+
copyTypings(indexTypings, root);
57+
}
58+
} catch (error) {
59+
// eslint-disable-next-line no-console
60+
console.error(error);
61+
process.exit(1);
62+
}
63+
}
64+
65+
run(sourceFiles);

0 commit comments

Comments
 (0)