Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7146c84

Browse files
committedOct 14, 2021
auto generate tsconfig files
1 parent 6b047b4 commit 7146c84

File tree

20 files changed

+393
-149
lines changed

20 files changed

+393
-149
lines changed
 

‎package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,21 @@
2525
"format:prettier": "prettier \"**/*.js\" \"**/*.ts\" --write --ignore-path .gitignore",
2626
"lint": "npm run lint:eslint && npm run lint:prettier",
2727
"format": "npm run format:eslint && npm run format:prettier",
28-
"storybook": "npm run analyze && start-storybook -p 6006 -s ./.storybook/images",
29-
"storybook:build": "npm run analyze && npm run build && build-storybook -s ./.storybook/images",
28+
"storybook": "npm run bootstrap && npm run analyze && start-storybook -p 6006 -s ./.storybook/images",
29+
"storybook:build": "npm run bootstrap && npm run analyze && npm run build && build-storybook -s ./.storybook/images",
3030
"analyze": "web-component-analyzer **/*.element.ts --outFile custom-elements.json",
3131
"test": "web-test-runner --coverage",
3232
"test:watch": "web-test-runner --watch",
33-
"bootstrap": "lerna bootstrap --ci",
3433
"build": "npm run build:css && lerna run build",
3534
"build:css": "postcss src/styles/index.css --base src/styles --dir out-css",
3635
"build:prod": "npm run clean && npm run lint && npm run test && npm run build",
3736
"clean": "rimraf out-css && lerna run clean",
3837
"lerna:publish": "npm run lint && npm run test && lerna publish from-package && npm run lerna-fix",
3938
"lerna:version-patch": "lerna version patch",
4039
"diff": "lerna diff",
41-
"lerna-fix": "lerna exec -- node ../../scripts/lerna-fix.mjs"
40+
"lerna-fix": "lerna exec -- node ../../scripts/lerna-fix.mjs",
41+
"postinstall": "npm run bootstrap",
42+
"bootstrap": "node ./scripts/generate-ts-config.js"
4243
},
4344
"engines": {
4445
"node": ">=16.8.0",
+21-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
719
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [
11-
{ "path": "../uui-base" },
12-
{ "path": "../uui-avatar" }
13-
]
20+
{
21+
"path": "../uui-avatar"
22+
}
23+
]
1424
}

‎packages/uui-avatar/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-base/tsconfig.json

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": []
1017
}
+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-button/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-checkbox/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-input/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-loader-bar/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}
+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-loader/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-radio/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-slider/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-table/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-tabs/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-tag/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎packages/uui-toggle/tsconfig.json

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js
2+
13
{
2-
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./lib",
5-
"rootDir": "./lib",
6-
"composite": true
7-
},
8-
"include": ["./**/*.ts"],
9-
"exclude": ["./**/*.test.ts"],
10-
"references": [{ "path": "../uui-base" }]
4+
"extends": "../../tsconfig.json",
5+
"compilerOptions": {
6+
"outDir": "./lib",
7+
"rootDir": "./lib",
8+
"composite": true
9+
},
10+
"include": [
11+
"./**/*.ts"
12+
],
13+
"exclude": [
14+
"./**/*.test.ts"
15+
],
16+
"references": [
17+
{
18+
"path": "../uui-base"
19+
}
20+
]
1121
}

‎scripts/generate-ts-config.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env node
2+
const path = require('path');
3+
const fs = require('fs');
4+
const {
5+
packageDirectoryNames,
6+
packagesRoot,
7+
packageNamespace,
8+
} = require('./packages');
9+
10+
const TSCONFIG_COMMENT = `// Don't edit this file directly. It is generated by /scripts/generate-ts-config.js\n\n`;
11+
12+
const tsConfigBase = {
13+
extends: '../../tsconfig.json',
14+
compilerOptions: {
15+
outDir: './lib',
16+
rootDir: './lib',
17+
composite: true,
18+
},
19+
include: ['./**/*.ts'],
20+
exclude: ['./**/*.test.ts'],
21+
};
22+
23+
const generatePackageTSConfig = () => {
24+
packageDirectoryNames.forEach(packageDirectoryName => {
25+
const packageDirectory = path.join(packagesRoot, packageDirectoryName);
26+
const packageJSONPath = path.join(packageDirectory, 'package.json');
27+
const packageJSONExists = fs.existsSync(packageJSONPath);
28+
29+
if (!packageJSONExists) {
30+
console.error();
31+
console.error(`Could not find package.json: ${packageJSONPath}`);
32+
console.error();
33+
//process.exit(1);
34+
}
35+
36+
if (packageJSONExists) {
37+
const packageJSONData = JSON.parse(
38+
fs.readFileSync(packageJSONPath).toString()
39+
);
40+
const { dependencies, devDependencies } = packageJSONData;
41+
const allDependencies = { ...dependencies, ...devDependencies };
42+
const dependencyNames = Object.keys(allDependencies);
43+
const internalDependencies = dependencyNames.filter(name =>
44+
name.startsWith(packageNamespace)
45+
);
46+
47+
const references = internalDependencies.map(name => {
48+
return { path: `../${name.replace(`${packageNamespace}/`, '')}` };
49+
});
50+
51+
const tsConfig = { ...tsConfigBase, references };
52+
const tsconfigPath = path.join(packageDirectory, 'tsconfig.json');
53+
54+
fs.writeFileSync(
55+
tsconfigPath,
56+
TSCONFIG_COMMENT + JSON.stringify(tsConfig, null, ' ')
57+
);
58+
59+
console.log(`Generated tsconfig for ${packageJSONData.name}`);
60+
}
61+
});
62+
};
63+
64+
generatePackageTSConfig();

‎scripts/packages.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const path = require('path');
2+
const { getDirectories } = require('./utils');
3+
4+
const packageNamespace = '@umbraco-ui';
5+
const packagesDirectoryName = 'packages';
6+
const packagesRoot = path.join(__dirname, '..', packagesDirectoryName);
7+
const packageDirectoryNames = getDirectories(packagesDirectoryName);
8+
9+
exports.packageNamespace = packageNamespace;
10+
exports.packagesDirectoryName = packagesDirectoryName;
11+
exports.packagesRoot = packagesRoot;
12+
exports.packageDirectoryNames = packageDirectoryNames;

‎scripts/utils.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env node
2+
const fs = require('fs');
3+
4+
const getDirectories = source =>
5+
fs
6+
.readdirSync(source, { withFileTypes: true })
7+
.filter(dirent => dirent.isDirectory())
8+
.map(dirent => dirent.name);
9+
10+
exports.getDirectories = getDirectories;

0 commit comments

Comments
 (0)
Please sign in to comment.