@rtorcato/js-tooling 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +129 -0
- package/dist/cli/commands/setup.js +218 -0
- package/dist/cli/generators/build.js +90 -0
- package/dist/cli/generators/git.js +133 -0
- package/dist/cli/generators/github-actions.js +261 -0
- package/dist/cli/generators/index.js +53 -0
- package/dist/cli/generators/linting.js +43 -0
- package/dist/cli/generators/package-json.js +162 -0
- package/dist/cli/generators/readme.js +224 -0
- package/dist/cli/generators/testing.js +78 -0
- package/dist/cli/generators/tsconfig.js +28 -0
- package/dist/cli/index.js +53 -0
- package/dist/cli/utils/install.js +28 -0
- package/package.json +160 -0
- package/scripts/README.md +8 -0
- package/scripts/commitmessage.sh +44 -0
- package/scripts/helloworld.sh +5 -0
- package/tooling/biome/biome.jsonc +47 -0
- package/tooling/commitlint/commitlint.mjs +4 -0
- package/tooling/esbuild/build-sample.mjs +21 -0
- package/tooling/esbuild/index.mjs +102 -0
- package/tooling/eslint/README.md +3 -0
- package/tooling/eslint/base.mjs +122 -0
- package/tooling/eslint/nextjs.mjs +22 -0
- package/tooling/eslint/package.json +35 -0
- package/tooling/eslint/types.d.ts +58 -0
- package/tooling/jest-presets/browser/jest-preset.mjs +14 -0
- package/tooling/jest-presets/node/jest-preset.mjs +13 -0
- package/tooling/nextjs/next.config.js +4 -0
- package/tooling/oxc/.gitkeep +0 -0
- package/tooling/oxc/README.md +1 -0
- package/tooling/playwright/playwright.config.ts +0 -0
- package/tooling/prettier/index.mjs +36 -0
- package/tooling/rolldown/.gitkeep +0 -0
- package/tooling/rollup/.gitkeep +0 -0
- package/tooling/semantic-release/docker.mjs +59 -0
- package/tooling/semantic-release/github.mjs +74 -0
- package/tooling/semantic-release/index.mjs +75 -0
- package/tooling/tsdown/.gitkeep +0 -0
- package/tooling/tsup/index.ts +50 -0
- package/tooling/tsup/tsconfig.cjs.json +7 -0
- package/tooling/tsup/tsconfig.esm.json +9 -0
- package/tooling/tsup/tsconfig.json +11 -0
- package/tooling/tsup/tsconfig.types.json +9 -0
- package/tooling/typescript/README.md +52 -0
- package/tooling/typescript/reset.d.ts +9 -0
- package/tooling/typescript/tsconfig.base.json +78 -0
- package/tooling/typescript/tsconfig.build.json +11 -0
- package/tooling/typescript/tsconfig.express.json +9 -0
- package/tooling/typescript/tsconfig.next.json +19 -0
- package/tooling/typescript/tsconfig.node.json +9 -0
- package/tooling/typescript/tsconfig.react.json +14 -0
- package/tooling/typescript/tsconfig.test.json +8 -0
- package/tooling/vellite/.gitkeep +0 -0
- package/tooling/vite/.gitkeep +0 -0
- package/tooling/vitest/vitest.config.mjs +22 -0
- package/tooling/vitest/vitest.config.react.mjs +27 -0
- package/tooling/vitest/vitest.setup.mjs +3 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Options } from 'tsup'
|
|
2
|
+
import { defineConfig } from 'tsup'
|
|
3
|
+
|
|
4
|
+
export type DefineConfig = ReturnType<typeof defineConfig>
|
|
5
|
+
|
|
6
|
+
export const getConfig: (customOptions: Options, env: string) => DefineConfig = (
|
|
7
|
+
customOptions: Options,
|
|
8
|
+
env: string
|
|
9
|
+
): DefineConfig => {
|
|
10
|
+
return defineConfig((options: Options = customOptions) => {
|
|
11
|
+
return baseOptions(options, env)
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const baseOptions = (options: Options, env: string): Options => {
|
|
16
|
+
const opts: Options = {
|
|
17
|
+
treeshake: true,
|
|
18
|
+
splitting: true,
|
|
19
|
+
// target: 'es2020',
|
|
20
|
+
// target: 'nodeNext',
|
|
21
|
+
format: ['cjs', 'esm'], // generate cjs and esm files
|
|
22
|
+
entry: [
|
|
23
|
+
// './src/index.ts',
|
|
24
|
+
'src/**/*.ts',
|
|
25
|
+
// './src/**/*!(index).ts?(x)',
|
|
26
|
+
// '!./src/**/*.spec.*',
|
|
27
|
+
// '!./src/**/*.stories.*',
|
|
28
|
+
],
|
|
29
|
+
skipNodeModulesBundle: true, // Skips building dependencies for node modules
|
|
30
|
+
minify: !options.watch && env === 'production',
|
|
31
|
+
bundle: false, //env === 'production',
|
|
32
|
+
clean: true, // clean up the dist folder
|
|
33
|
+
dts: true, // generate dts file for main module
|
|
34
|
+
// sourcemap: env === 'production', // source map is only available in prod
|
|
35
|
+
// sourcemap: true,
|
|
36
|
+
// outDir: env === 'production' ? 'dist' : 'lib',
|
|
37
|
+
// outDir: 'dist',
|
|
38
|
+
// tsconfig: path.resolve(__dirname, './tsconfig.build.json'),
|
|
39
|
+
// esbuildOptions(options, context) {
|
|
40
|
+
// options.outbase = './'
|
|
41
|
+
// },
|
|
42
|
+
// external: ['react'],
|
|
43
|
+
...options,
|
|
44
|
+
// banner: {js: '"use client";'},
|
|
45
|
+
// dts: {
|
|
46
|
+
// footer: "declare module 'knex/types/tables';"
|
|
47
|
+
// },
|
|
48
|
+
}
|
|
49
|
+
return opts
|
|
50
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./../typescript/internal-package.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json",
|
|
5
|
+
"incremental": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"baseUrl": "."
|
|
8
|
+
},
|
|
9
|
+
"include": ["./src/**/*.ts", "index.ts"],
|
|
10
|
+
"exclude": ["node_modules"]
|
|
11
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# `tsconfig`
|
|
2
|
+
|
|
3
|
+
These are base shared `tsconfig.json` files from which all other `tsconfig.json`'s inherit.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
1. **Install this package** (if published as a package):
|
|
8
|
+
```sh
|
|
9
|
+
pnpm add -D @your-org/tsconfig
|
|
10
|
+
# or
|
|
11
|
+
npm install --save-dev @your-org/tsconfig
|
|
12
|
+
# or
|
|
13
|
+
yarn add -D @your-org/tsconfig
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
2. **Extend the relevant config in your project `tsconfig.json`:**
|
|
17
|
+
```jsonc
|
|
18
|
+
{
|
|
19
|
+
"extends": "./path/to/tooling/typescript/tsconfig.base.json", // or tsconfig.react.jsonc, etc.
|
|
20
|
+
// ...your overrides
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
Replace the path with the config that matches your project type:
|
|
24
|
+
- `tsconfig.base.jsonc`: General base config
|
|
25
|
+
- `tsconfig.build.jsonc`: For npm package/library builds
|
|
26
|
+
- `tsconfig.react.jsonc`: For React apps
|
|
27
|
+
- `tsconfig.next.jsonc`: For Next.js apps
|
|
28
|
+
- `tsconfig.node.jsonc`: For Node.js/Express APIs
|
|
29
|
+
- `tsconfig.express.jsonc`: (If used) For Express APIs
|
|
30
|
+
|
|
31
|
+
3. **Customizing:**
|
|
32
|
+
You can override or add any settings in your own `tsconfig.json` as needed.
|
|
33
|
+
|
|
34
|
+
## Example
|
|
35
|
+
|
|
36
|
+
```jsonc
|
|
37
|
+
{
|
|
38
|
+
"extends": "../tooling/typescript/tsconfig.react.json",
|
|
39
|
+
"compilerOptions": {
|
|
40
|
+
"baseUrl": ".",
|
|
41
|
+
"paths": {
|
|
42
|
+
"@/*": ["src/*"]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"include": ["src"]
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Notes
|
|
50
|
+
- These configs are meant to be shared and extended, not used directly.
|
|
51
|
+
- Pick the config that matches your project type for best results.
|
|
52
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Do not add any other lines of code to this file!
|
|
2
|
+
import '@total-typescript/ts-reset'
|
|
3
|
+
|
|
4
|
+
// https://www.totaltypescript.com/ts-reset
|
|
5
|
+
// With ts-reset:
|
|
6
|
+
// 👍 .json (in fetch) and JSON.parse both return unknown
|
|
7
|
+
// ✅ .filter(Boolean) behaves EXACTLY how you expect
|
|
8
|
+
// 🥹 array.includes is widened to be more ergonomic
|
|
9
|
+
// 🚀 And several more changes!
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// 🔧 Output & Module Resolution
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"module": "esnext",
|
|
7
|
+
"target": "esnext",
|
|
8
|
+
// "module": "esnext", //
|
|
9
|
+
// "moduleResolution": "node", // Prefer "bundler" if you're using Vite, esbuild, etc.
|
|
10
|
+
// "target": "esnext", //
|
|
11
|
+
"lib": ["ES2022"], // Specify library files to be included in the compilation
|
|
12
|
+
"baseUrl": ".", // Base directory to resolve non-relative module names
|
|
13
|
+
"rootDir": "src",
|
|
14
|
+
"outDir": "dist",
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
// 🔍 JavaScript Support
|
|
18
|
+
"allowJs": true, // Allow JavaScript files to be compiled
|
|
19
|
+
"checkJs": true, // Enable type checking on JavaScript files
|
|
20
|
+
"resolveJsonModule": true, // Allow importing JSON files
|
|
21
|
+
"isolatedModules": true, // Ensure that each file can be safely transpiled independently
|
|
22
|
+
"esModuleInterop": true, // Enables emit interoperability between CommonJS and ES Modules
|
|
23
|
+
"allowSyntheticDefaultImports": true, // recommend enabling this for smoother interop
|
|
24
|
+
|
|
25
|
+
// ⚙️ Module Detection
|
|
26
|
+
"moduleDetection": "force", // Force module detection
|
|
27
|
+
|
|
28
|
+
// 📈 Performance
|
|
29
|
+
"skipLibCheck": true, // Skip type checking of declaration files
|
|
30
|
+
"incremental": true, // Enable incremental compilation
|
|
31
|
+
"disableSourceOfProjectReferenceRedirect": true, // Disable source of project reference redirect
|
|
32
|
+
|
|
33
|
+
// 🚨 Strict Type Checking
|
|
34
|
+
"strict": true, // Enable all strict type checking options
|
|
35
|
+
"noUncheckedIndexedAccess": true, // Disallow accessing an index signature with an arbitrary key
|
|
36
|
+
"noImplicitAny": true, // Disallow implicit any type
|
|
37
|
+
"noImplicitReturns": true, // Disallow functions that do not return a value
|
|
38
|
+
"noImplicitOverride": true, // Ensure override keyword is used
|
|
39
|
+
"noImplicitThis": true, // Disallow 'this' with an implicit any type
|
|
40
|
+
"noPropertyAccessFromIndexSignature": true, // Disallow property access from index signature
|
|
41
|
+
|
|
42
|
+
// 🧹 Lint-Like Settings
|
|
43
|
+
"noUnusedLocals": true, // Disallow unused locals
|
|
44
|
+
"noUnusedParameters": true, // Disallow unused parameters
|
|
45
|
+
"noFallthroughCasesInSwitch": true, // Disallow fallthrough cases in switch statements
|
|
46
|
+
|
|
47
|
+
// 📦 Types & Declarations
|
|
48
|
+
"types": ["node", "vitest"], // Specify type declaration files to be included in the compilation
|
|
49
|
+
"declaration": false, // Do not generate .d.ts files
|
|
50
|
+
"declarationMap": false, // Do not generate sourcemaps for d.ts files
|
|
51
|
+
|
|
52
|
+
// 🛑 Emit Settings
|
|
53
|
+
"noEmit": true, // Do not emit output files
|
|
54
|
+
"sourceMap": true, // Generate sourcemaps for .ts files
|
|
55
|
+
|
|
56
|
+
"paths": { // Path mapping for module resolution
|
|
57
|
+
"~/*": ["./src/*"],
|
|
58
|
+
"@/*": ["./src/*"]
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"include": ["src/**/*", "index.d.ts"], // Include files in the src directory and index.d.ts
|
|
62
|
+
"exclude": [
|
|
63
|
+
"node_modules",
|
|
64
|
+
"build",
|
|
65
|
+
"dist",
|
|
66
|
+
".next",
|
|
67
|
+
".expo",
|
|
68
|
+
"OLD",
|
|
69
|
+
"**/*.test.ts",
|
|
70
|
+
"**/*.test.tsx",
|
|
71
|
+
"**/*.spec.ts",
|
|
72
|
+
"**/*.spec.tsx",
|
|
73
|
+
".turbo",
|
|
74
|
+
"out",
|
|
75
|
+
"not-used",
|
|
76
|
+
"vitest.config.ts"
|
|
77
|
+
] // Exclude directories from compilation
|
|
78
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noEmit": false, // Emit output files
|
|
5
|
+
"emitDeclarationOnly": true, // Emit JS and .d.ts files
|
|
6
|
+
"declaration": true, // Generate .d.ts files
|
|
7
|
+
"declarationMap": true, // (optional) Generate sourcemaps for d.ts files
|
|
8
|
+
"outDir": "dist" // Output directory for build
|
|
9
|
+
},
|
|
10
|
+
"exclude": ["dist", "node_modules", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"]
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": ["ES2022"], // Only include ES libs, no DOM
|
|
5
|
+
"types": ["node", "express", "vitest"], // Add express types for API development
|
|
6
|
+
},
|
|
7
|
+
"include": ["src", "index.d.ts"],
|
|
8
|
+
"exclude": ["node_modules", "dist", "build", "test", "**/*.test.ts", "**/*.spec.ts"]
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"jsx": "preserve", // Let Next.js handle JSX transformation
|
|
5
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"], // Include DOM types for browser APIs
|
|
6
|
+
"module": "esnext", // Next.js expects ESNext modules
|
|
7
|
+
"moduleResolution": "bundler", // Modern module resolution for Next.js
|
|
8
|
+
"allowJs": true, // Allow JavaScript files
|
|
9
|
+
"esModuleInterop": true, // Interop for CommonJS/ESM
|
|
10
|
+
"types": ["react", "tailwindcss", "vitest"],
|
|
11
|
+
"plugins": [ { "name": "next" } ], // Next.js plugin for TypeScript
|
|
12
|
+
"paths": {
|
|
13
|
+
"~/*": ["./src/*"],
|
|
14
|
+
"@/*": ["./src/*"]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"include": ["next-env.d.ts", "src", "pages", "app", "components", "types", "index.d.ts"],
|
|
18
|
+
"exclude": ["node_modules", "dist", ".next", "build", "out"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"jsx": "react-jsx", // Use the new JSX transform for React 17+
|
|
5
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],// Include DOM types for browser APIs
|
|
6
|
+
"types": ["react", "react-dom", "tailwindcss", "vitest"],
|
|
7
|
+
"paths": {
|
|
8
|
+
"~/*": ["./src/*"],
|
|
9
|
+
"@/*": ["./src/*"]
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"include": ["src", "index.d.ts", "types"],
|
|
13
|
+
"exclude": ["node_modules", "dist", "build", "out", "**/*.test.ts", "**/*.spec.ts"]
|
|
14
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { dirname, resolve } from 'node:path'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
import { defineConfig } from 'vitest/config'
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
test: {
|
|
9
|
+
globals: true,
|
|
10
|
+
environment: 'node',
|
|
11
|
+
coverage: {
|
|
12
|
+
provider: 'istanbul', // or 'v8'
|
|
13
|
+
reporter: ['text', 'json', 'html'],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
resolve: {
|
|
17
|
+
alias: [
|
|
18
|
+
{ find: '@', replacement: resolve(__dirname, './src') },
|
|
19
|
+
{ find: '~', replacement: resolve(__dirname, './src') },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import base from '@rtorcato/js-tooling/vitest/config'
|
|
2
|
+
import react from '@vitejs/plugin-react'
|
|
3
|
+
import { dirname, resolve } from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import { defineConfig, mergeConfig } from 'vitest/config'
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
8
|
+
|
|
9
|
+
export default mergeConfig(
|
|
10
|
+
base,
|
|
11
|
+
defineConfig({
|
|
12
|
+
plugins: [react()],
|
|
13
|
+
test: {
|
|
14
|
+
environment: 'jsdom',
|
|
15
|
+
include: ['src/**/*.{test,spec}.{js,jsx,ts,tsx}'],
|
|
16
|
+
css: true, // ← Vitest will stub every *.css / *.module.css import
|
|
17
|
+
exclude: ['OLD/**'],
|
|
18
|
+
setupFiles: ['./vitest.setup.ts'],
|
|
19
|
+
},
|
|
20
|
+
resolve: {
|
|
21
|
+
alias: [
|
|
22
|
+
{ find: '@', replacement: resolve(__dirname, './src') },
|
|
23
|
+
{ find: '~', replacement: resolve(__dirname, './src') },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
)
|