Skip to content

Commit 6291e86

Browse files
committed
Initialize workspace setup
1 parent ee82fea commit 6291e86

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3340
-0
lines changed

.editorconfig

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/coverage/
2+
/docs/
3+
/packages/

.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./packages/build-config/templates/eslint/lib.eslintrc.cjs');

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/node_modules/
2+
/packages/*/node_modules/
3+
/coverage/
4+
/docs/

package.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"private": true,
3+
"name": "ag-grid-devtools",
4+
"version": "0.0.1",
5+
"scripts": {
6+
"ci": "pnpm run verify && pnpm run build",
7+
"build": "pnpm run build:lib && pnpm run build:docs && pnpm run coverage",
8+
"build:lib": "pnpm run --recursive --parallel build",
9+
"build:docs": "typedoc",
10+
"lint": "pnpm run '/^lint:.*/'",
11+
"lint:eslint": "eslint --ext js,cjs,mjs,ts --max-warnings 0 .",
12+
"lint:typescript": "tsc --noEmit",
13+
"verify": "pnpm run lint && pnpm run --recursive --parallel verify",
14+
"test": "vitest run",
15+
"coverage": "vitest run --coverage",
16+
"coverage:report": "vitest run --coverage --config ./report.vitest.config.ts",
17+
"watch:test": "vitest watch"
18+
},
19+
"peerDependencies": {
20+
"@vitest/coverage-v8": "^0.34",
21+
"typedoc": "^0.25",
22+
"typescript": "^5",
23+
"vite": "^4",
24+
"vitest": "^0.34"
25+
}
26+
}

packages/build-config/.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./templates/eslint/lib.eslintrc.cjs');

packages/build-config/package.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"private": true,
3+
"name": "@ag-grid-devtools/build-config",
4+
"version": "0.0.1",
5+
"license": "MIT",
6+
"description": "Build tool configuration",
7+
"author": "AG Grid <[email protected]>",
8+
"scripts": {
9+
"lint": "eslint --ext js,cjs,mjs,ts --max-warnings 0 .",
10+
"verify": "pnpm run lint"
11+
},
12+
"dependencies": {
13+
"@types/node": "20.5.9",
14+
"@types/react": "18.2.21",
15+
"@typescript-eslint/eslint-plugin": "6.6.0",
16+
"@typescript-eslint/parser": "6.6.0",
17+
"@vitejs/plugin-react-swc": "3.3.2",
18+
"@vitest/coverage-v8": "0.34.3",
19+
"eslint": "8.48.0",
20+
"eslint-config-prettier": "9.0.0",
21+
"eslint-plugin-prettier": "5.0.0",
22+
"eslint-plugin-react-hooks": "4.6.0",
23+
"eslint-plugin-vitest": "0.3.1",
24+
"prettier": "3.0.3",
25+
"rollup-plugin-preserve-shebang": "1.0.1",
26+
"typescript": "5.2.2",
27+
"vite": "4.4.9",
28+
"vite-plugin-dts": "3.5.3",
29+
"vitest": "0.34.3"
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './templates/prettier/prettier.config.mjs';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const rules = require('./rules.cjs');
2+
3+
module.exports = {
4+
root: true,
5+
env: {
6+
es2022: true,
7+
},
8+
extends: ['plugin:vitest/recommended', 'plugin:prettier/recommended'],
9+
plugins: ['@typescript-eslint', 'vitest'],
10+
parser: '@typescript-eslint/parser',
11+
parserOptions: {
12+
ecmaVersion: 'latest',
13+
sourceType: 'module',
14+
},
15+
overrides: [
16+
{
17+
files: ['.eslintrc.cjs'],
18+
env: {
19+
node: true,
20+
},
21+
parserOptions: {
22+
sourceType: 'script',
23+
},
24+
},
25+
],
26+
rules,
27+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const base = require('./base.eslintrc.cjs');
2+
3+
module.exports = {
4+
...base,
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const base = require('./base.eslintrc.cjs');
2+
3+
module.exports = {
4+
...base,
5+
extends: ['plugin:react-hooks/recommended', ...base.extends],
6+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
'no-warning-comments': [
3+
'warn',
4+
{
5+
terms: ['fixme'],
6+
},
7+
],
8+
'prettier/prettier': 'warn',
9+
'vitest/valid-title': [
10+
'error',
11+
{
12+
allowArguments: true,
13+
},
14+
],
15+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
printWidth: 100,
3+
semi: true,
4+
singleQuote: true,
5+
useTabs: false,
6+
tabWidth: 2,
7+
trailingComma: 'all',
8+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"noEmit": true,
4+
"target": "ES2022",
5+
"useDefineForClassFields": true,
6+
"module": "ESNext",
7+
"lib": ["ES2022"],
8+
"skipLibCheck": true,
9+
"moduleResolution": "bundler",
10+
"allowImportingTsExtensions": true,
11+
"resolveJsonModule": true,
12+
"isolatedModules": true,
13+
"strict": true
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://typedoc.org/schema.json",
3+
"disableSources": true
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vite';
2+
3+
export default defineConfig({
4+
build: {
5+
sourcemap: true,
6+
},
7+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import './rollup-plugin-preserve-shebang/index.d.ts';
2+
import shebang from 'rollup-plugin-preserve-shebang';
3+
import { defineConfig, mergeConfig } from 'vite';
4+
5+
import base from './node.vite.config';
6+
7+
export default mergeConfig(
8+
base,
9+
defineConfig({
10+
plugins: [shebang()],
11+
}),
12+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig, mergeConfig } from 'vite';
2+
import dts from 'vite-plugin-dts';
3+
4+
import base from './node.vite.config';
5+
6+
export default mergeConfig(
7+
base,
8+
defineConfig({
9+
plugins: [
10+
dts({
11+
exclude: ['node_modules/**', '*.config.ts', '**/*.test.ts'],
12+
}),
13+
],
14+
}),
15+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { defineConfig, mergeConfig } from 'vite';
2+
3+
import base from './base.vite.config';
4+
5+
const NODE_MODULES = [
6+
'assert',
7+
'buffer',
8+
'child_process',
9+
'crypto',
10+
'events',
11+
'fs',
12+
'fs/promises',
13+
'module',
14+
'net',
15+
'os',
16+
'path',
17+
'perf_hooks',
18+
'process',
19+
'stream',
20+
'url',
21+
'util',
22+
];
23+
24+
export default mergeConfig(
25+
base,
26+
defineConfig({
27+
build: {
28+
rollupOptions: {
29+
external: [...NODE_MODULES, /^node:/],
30+
},
31+
},
32+
}),
33+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig, mergeConfig } from 'vite';
2+
import react from '@vitejs/plugin-react-swc';
3+
4+
import base from './base.vite.config';
5+
6+
export default mergeConfig(
7+
base,
8+
defineConfig({
9+
plugins: [react()],
10+
}),
11+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module 'rollup-plugin-preserve-shebang' {
2+
import type { Plugin } from 'vite';
3+
export default function shebang(options?: { shebang?: string }): Plugin;
4+
}

packages/build-config/tsconfig.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": ["./templates/tsc/tsconfig.json"],
3+
"include": ["templates"],
4+
"compilerOptions": {
5+
"composite": true
6+
}
7+
}

packages/build-tools/.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@ag-grid-devtools/build-config/templates/eslint/lib.eslintrc.cjs');

packages/build-tools/package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"private": true,
3+
"name": "@ag-grid-devtools/build-tools",
4+
"version": "0.0.1",
5+
"license": "MIT",
6+
"description": "Custom build tools",
7+
"author": "AG Grid <[email protected]>",
8+
"scripts": {
9+
"pkg": "./scripts/pkg",
10+
"lint": "eslint --ext cjs --max-warnings 0 .",
11+
"verify": "pnpm run lint"
12+
},
13+
"devDependencies": {
14+
"@ag-grid-devtools/build-config": "workspace:*"
15+
}
16+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '@ag-grid-devtools/build-config/templates/prettier/prettier.config.mjs';

packages/build-tools/scripts/pkg

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/usr/bin/env node
2+
const fs = require('fs');
3+
const path = require('path');
4+
const process = require('process');
5+
6+
const [inputPath, outputPath] = process.argv.slice(2);
7+
8+
class ExitError extends Error {
9+
code;
10+
constructor(code, message) {
11+
super(`Error: ${message}`);
12+
this.name = ExitError.name;
13+
this.code = code;
14+
}
15+
}
16+
17+
try {
18+
if (!inputPath) throw new ExitError(1, 'Missing package.json input path');
19+
const inputPkgPath =
20+
path.basename(inputPath) === 'package.json' ? inputPath : path.join(inputPath, 'package.json');
21+
const pkgSource = (() => {
22+
try {
23+
return fs.readFileSync(inputPkgPath, 'utf-8');
24+
} catch (error) {
25+
throw new ExitError(1, `Failed to read package.json: ${inputPkgPath} (${error.code})\n`);
26+
}
27+
})();
28+
const pkg = (() => {
29+
try {
30+
return JSON.parse(pkgSource);
31+
} catch {
32+
throw new ExitError(1, `Invalid package.json contents: ${inputPkgPath}\n`);
33+
}
34+
})();
35+
const {
36+
name,
37+
version,
38+
license,
39+
description,
40+
author,
41+
repository,
42+
keywords,
43+
dependencies,
44+
pkg: overrides,
45+
} = pkg;
46+
const json = `${JSON.stringify(
47+
{
48+
name,
49+
version,
50+
license,
51+
description,
52+
author,
53+
repository,
54+
keywords,
55+
...overrides,
56+
dependencies: dependencies
57+
? // This assumes all workspace packages share the same version number
58+
fixWorkspaceDependencyVersions(dependencies, version)
59+
: undefined,
60+
},
61+
null,
62+
2,
63+
)}\n`;
64+
if (outputPath) {
65+
try {
66+
fs.writeFileSync(outputPath, json);
67+
exit(0);
68+
} catch (error) {
69+
throw new ExitError(1, `Failed to write output package.json: ${outputPath} (${error.code})`);
70+
}
71+
} else {
72+
process.stdout.write(json, (error) => {
73+
if (error) {
74+
exit(1, `Failed to write output JSON: (${error.code})`);
75+
} else {
76+
exit(0);
77+
}
78+
});
79+
}
80+
} catch (error) {
81+
if (error instanceof ExitError) {
82+
exit(error.code, error.message);
83+
} else {
84+
throw error;
85+
}
86+
}
87+
88+
function fixWorkspaceDependencyVersions(dependencies, workspaceVersion) {
89+
return Object.fromEntries(
90+
Object.entries(dependencies).map((dependency) => {
91+
const [name, version] = dependency;
92+
if (version === 'workspace:*') return [name, workspaceVersion];
93+
return dependency;
94+
}),
95+
);
96+
}
97+
98+
function exit(code, message) {
99+
if (typeof message === 'string') process.stderr.write(`${message}\n`);
100+
process.exit(code);
101+
}

packages/types/.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dist/

packages/types/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dist/

packages/types/lib.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)