@mateoserrano/simple-config 1.0.0 → 1.1.0

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/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # Typescript Utilities
2
-
3
- ### Development dependencies
4
-
5
- 1. Typescript
6
- 2. ESLint
7
- 3. Prettier
8
- 4. lint-staged
9
- 5. Husky
1
+ # Typescript Utilities
2
+
3
+ ### Development dependencies
4
+
5
+ 1. Typescript
6
+ 2. ESLint
7
+ 3. Prettier
8
+ 4. lint-staged
9
+ 5. Husky
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mateoserrano/simple-config",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Initialize ESLint, Prettier, Husky and lint-staged for modern TypeScript projects",
@@ -21,5 +21,20 @@
21
21
  },
22
22
  "engines": {
23
23
  "node": ">=20"
24
+ },
25
+ "devDependencies": {
26
+ "@eslint/js": "9.39.1",
27
+ "@types/node": "25.0.3",
28
+ "eslint": "9.39.1",
29
+ "eslint-config-prettier": "10.1.8",
30
+ "globals": "17.0.0",
31
+ "husky": "9.1.7",
32
+ "lint-staged": "16.2.7",
33
+ "prettier": "3.6.2",
34
+ "tsx": "4.20.6",
35
+ "typescript-eslint": "8.46.4"
36
+ },
37
+ "scripts": {
38
+ "prepare": "husky"
24
39
  }
25
40
  }
package/scripts/init.js CHANGED
@@ -1,128 +1,13 @@
1
- #!/usr/bin/env node
2
-
3
- import { execSync } from 'node:child_process'
4
- import { cpSync, existsSync, mkdirSync } from 'node:fs'
5
- import { basename, join } from 'node:path'
6
- import { fileURLToPath } from 'node:url';
7
-
8
- // Dependencies
9
- const devDeps = {
10
- tsx: {
11
- package: 'tsx',
12
- version: '4.20.6',
13
- },
14
- eslint: {
15
- package: 'eslint',
16
- version: '9.39.1',
17
- },
18
- typescriptEslint: {
19
- package: 'typescript-eslint',
20
- version: '8.46.4',
21
- },
22
- eslintJs: {
23
- package: '@eslint/js',
24
- version: '9.39.1',
25
- },
26
- prettier: {
27
- package: 'prettier',
28
- version: '3.6.2',
29
- },
30
- eslintConfigPrettier: {
31
- package: 'eslint-config-prettier',
32
- version: '10.1.8',
33
- },
34
- lintStaged: {
35
- package: 'lint-staged',
36
- version: '16.2.7',
37
- },
38
- husky: {
39
- package: 'husky',
40
- version: '9.1.7',
41
- },
42
- };
43
- const devDepFiles = {
44
- eslint: [
45
- {
46
- source: 'eslint.config.js',
47
- target: '.',
48
- },
49
- ],
50
- prettier: [
51
- {
52
- source: 'prettier.config.js',
53
- target: '.',
54
- },
55
- ],
56
- lintStaged: [
57
- {
58
- source: 'lint-staged.config.js',
59
- target: '.',
60
- },
61
- ],
62
- typescript: [
63
- {
64
- source: 'tsconfig.json',
65
- target: '.',
66
- },
67
- ],
68
- };
69
-
70
- function copyFileToFolderOrSkip(sourceFile, targetFolder) {
71
- const sourceFileName = basename(sourceFile);
72
- if (!existsSync(sourceFile)) {
73
- console.error(`Source file not found: ${sourceFile}`);
74
- return;
75
- }
76
-
77
- if (existsSync(join(targetFolder, sourceFileName))) {
78
- console.log(`File ${sourceFileName} already exists in ${targetFolder}. Skipping...`);
79
- return;
80
- }
81
- if (!existsSync(targetFolder)) {
82
- console.log(`Creating folder ${targetFolder}...`);
83
- mkdirSync(targetFolder, { recursive: true });
84
- }
85
-
86
- const destinationPath = join(targetFolder, sourceFileName);
87
- cpSync(sourceFile, destinationPath);
88
- }
89
-
90
- let installNames = [];
91
- for (const dep of Object.values(devDeps)) {
92
- installNames.push(`${dep.package}@${dep.version}`);
93
- }
94
-
95
- const installCmd = `npm install -D ${installNames.join(' ')}`;
96
- const installHuskyCmd = 'npx husky install';
97
- const setupHuskyCmd = 'npx husky add .husky/pre-commit "npx lint-staged"';
98
-
99
- const runSilent = cmd => execSync(cmd, { stdio: 'ignore' });
100
- const cwd = process.cwd();
101
-
102
- if (!existsSync(join(cwd, 'package.json'))) {
103
- console.error('No package.json found.');
104
- process.exit(1);
105
- }
106
-
107
- const repositoryDirname = fileURLToPath(new URL('.', import.meta.url));
108
- const templatesFolder = join(repositoryDirname, '../templates');
109
-
110
- // Install dependencies
111
- console.log('Installing dependencies...');
112
- runSilent(installCmd);
113
-
114
- // Husky
115
- console.log('Configuring Husky...');
116
- runSilent(installHuskyCmd);
117
- runSilent(setupHuskyCmd);
118
-
119
- // Copy files
120
- for (const fileGroup of Object.values(devDepFiles)) {
121
- for (const file of fileGroup) {
122
- const source = join(templatesFolder, file.source);
123
- const targetFolder = join(cwd, file.target);
124
- copyFileToFolderOrSkip(source, targetFolder);
125
- }
126
- }
127
-
128
- console.log('\nDependencies installed successfully.');
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ assertValidNodePackage,
5
+ installDependencies,
6
+ configureHusky,
7
+ copyConfigurationFiles,
8
+ } from '../src/index.js'
9
+
10
+ assertValidNodePackage()
11
+ installDependencies()
12
+ configureHusky()
13
+ copyConfigurationFiles()
@@ -1,16 +1,17 @@
1
- import js from '@eslint/js';
2
- import tseslint from 'typescript-eslint';
3
- import eslintConfigPrettier from 'eslint-config-prettier';
4
-
5
- export default tseslint.config(
6
- js.configs.recommended,
7
- ...tseslint.configs.recommended,
8
- eslintConfigPrettier,
9
- {
10
- rules: {
11
- '@typescript-eslint/no-unused-vars': 'warn',
12
- '@typescript-eslint/no-explicit-any': 'warn',
13
- 'no-console': 'off',
14
- },
15
- }
16
- );
1
+ import globals from 'globals'
2
+
3
+ export default [
4
+ {
5
+ files: ['**/*.js', '**/*.ts'],
6
+ languageOptions: {
7
+ ecmaVersion: 'latest',
8
+ sourceType: 'module',
9
+ globals: {
10
+ ...globals.node,
11
+ },
12
+ },
13
+ rules: {
14
+ 'no-console': 'off',
15
+ },
16
+ },
17
+ ]
@@ -1,6 +1,3 @@
1
- export default {
2
- '*.{ts,tsx,js,json}': [
3
- 'eslint --fix',
4
- 'prettier --write',
5
- ],
6
- };
1
+ export default {
2
+ '*.{ts,tsx,js,json}': ['eslint --fix', 'prettier --write'],
3
+ }
@@ -1,6 +1,6 @@
1
- export default {
2
- semi: false,
3
- singleQuote: true,
4
- trailingComma: 'all',
5
- printWidth: 100,
6
- };
1
+ export default {
2
+ semi: false,
3
+ singleQuote: true,
4
+ trailingComma: 'all',
5
+ printWidth: 100,
6
+ }
@@ -1,15 +1,15 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "outDir": "dist",
6
- "rootDir": "src",
7
- "esModuleInterop": true,
8
- "moduleResolution": "node",
9
- "resolveJsonModule": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "strict": true,
12
- "skipLibCheck": true,
13
- },
14
- "include": ["src/**/*.ts"]
15
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "outDir": "dist",
6
+ "rootDir": "src",
7
+ "esModuleInterop": true,
8
+ "moduleResolution": "node",
9
+ "resolveJsonModule": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "strict": true,
12
+ "skipLibCheck": true
13
+ },
14
+ "include": ["src/**/*.ts"]
15
+ }