@mateoserrano/simple-config 1.2.3 → 1.2.5
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/CHANGELOG.md +15 -0
- package/README.md +23 -23
- package/dist/core/commands/command.install.factory.js +3 -1
- package/dist/core/commands/command.install.factory.spec.js +1 -3
- package/dist/core/files/file.copier.js +10 -4
- package/dist/core/files/file.copier.spec.js +9 -1
- package/dist/domain/helpers.js +3 -3
- package/dist/wires/constants.js +24 -4
- package/package.json +4 -2
- package/templates/template.eslint.config.js +52 -0
- package/templates/{lint-staged.config.js → template.lint-staged.config.js} +1 -1
- package/templates/{prettier.config.js → template.prettier.config.js} +1 -2
- package/templates/template.tsconfig.build.json +24 -0
- package/templates/eslint.config.js +0 -39
- /package/templates/{tsconfig.json → template.tsconfig.json} +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
+
|
|
5
|
+
### [1.2.5](https://github.com/Mateo-Serrano-24504/simple-config/compare/v1.2.4...v1.2.5) (2026-01-29)
|
|
6
|
+
|
|
7
|
+
### [1.2.4](https://github.com/Mateo-Serrano-24504/simple-config/compare/v1.2.3...v1.2.4) (2026-01-28)
|
|
8
|
+
|
|
9
|
+
### [1.2.3](https://github.com/Mateo-Serrano-24504/simple-config/compare/v1.2.2...v1.2.3) (2026-01-18)
|
|
10
|
+
|
|
11
|
+
### [1.2.2](https://github.com/Mateo-Serrano-24504/simple-config/compare/v1.2.1...v1.2.2) (2026-01-18)
|
|
12
|
+
|
|
13
|
+
### [1.2.1](https://github.com/Mateo-Serrano-24504/simple-config/compare/v1.2.0...v1.2.1) (2026-01-18)
|
|
14
|
+
|
|
15
|
+
## [1.2.0](https://github.com/Mateo-Serrano-24504/simple-config/compare/v1.1.9...v1.2.0) (2026-01-18)
|
package/README.md
CHANGED
|
@@ -9,17 +9,18 @@
|
|
|
9
9
|
This package includes some simple configuration files for TypeScript
|
|
10
10
|
development. When installed, this package will include a script that:
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
[development dependencies](#development-dependencies) section.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
- Installs a set of **development dependencies**. See more in the
|
|
13
|
+
[development dependencies](#development-dependencies) section.
|
|
14
|
+
- Creates template configuration files for:
|
|
15
|
+
- TypeScript
|
|
16
|
+
- ESLint (Flat Config)
|
|
17
|
+
- Prettier
|
|
18
|
+
- lint-staged
|
|
19
19
|
|
|
20
20
|
See more in the [configuration files](#configuration-files) section.
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
|
|
22
|
+
- Initializes **Husky** and registers a working `pre-commit` hook that
|
|
23
|
+
runs lint-staged.
|
|
23
24
|
|
|
24
25
|
## Installation
|
|
25
26
|
|
|
@@ -37,25 +38,25 @@ npx dev-config
|
|
|
37
38
|
|
|
38
39
|
After having run the script, the following dependencies will have been installed:
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
- `typescript`
|
|
42
|
+
- `eslint`
|
|
43
|
+
- `typescript-eslint`
|
|
44
|
+
- `@eslint/js`
|
|
45
|
+
- `prettier`
|
|
46
|
+
- `eslint-config-prettier`
|
|
47
|
+
- `lint-staged`
|
|
48
|
+
- `husky`
|
|
49
|
+
- `globals`
|
|
49
50
|
|
|
50
51
|
## Configuration files
|
|
51
52
|
|
|
52
53
|
After having run the script, the following configuration files will have been
|
|
53
54
|
created:
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
- `template.eslint.config.js`
|
|
57
|
+
- `template.prettier.config.js`
|
|
58
|
+
- `template.lint-staged.config.js`
|
|
59
|
+
- `tsconfig.json`
|
|
59
60
|
|
|
60
61
|
As they are templates, you might modify any of these to suit your needs, although
|
|
61
62
|
they should be enough to get you started.
|
|
@@ -66,4 +67,3 @@ to ESM.
|
|
|
66
67
|
## 📄 License
|
|
67
68
|
|
|
68
69
|
MIT
|
|
69
|
-
|
|
@@ -6,6 +6,8 @@ export class CommandInstallFactory {
|
|
|
6
6
|
this.commandSilentFactory = new CommandSilentFactory();
|
|
7
7
|
}
|
|
8
8
|
create(dependencies) {
|
|
9
|
-
return this.commandSilentFactory.create(`npm i -D ${dependencies
|
|
9
|
+
return this.commandSilentFactory.create(`npm i -D ${dependencies
|
|
10
|
+
.map((value) => this.dependencyRepresentationFactory.create(value))
|
|
11
|
+
.join(' ')} --save-exact`);
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -4,9 +4,7 @@ import { CommandInstallFactory } from './command.install.factory.js';
|
|
|
4
4
|
function makeDependency(overrides = {}) {
|
|
5
5
|
return {
|
|
6
6
|
name: faker.word.noun(),
|
|
7
|
-
...(faker.datatype.boolean()
|
|
8
|
-
? { version: faker.system.semver() }
|
|
9
|
-
: {}),
|
|
7
|
+
...(faker.datatype.boolean() ? { version: faker.system.semver() } : {}),
|
|
10
8
|
...overrides,
|
|
11
9
|
};
|
|
12
10
|
}
|
|
@@ -11,22 +11,28 @@ export class FileCopier {
|
|
|
11
11
|
this.fileHandler.createFolder(folder);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
copyFileToFolder(fileName, folder) {
|
|
14
|
+
copyFileToFolder(fileName, folder, newName) {
|
|
15
15
|
if (!this.fileHandler.verifyIfFileExists(fileName)) {
|
|
16
16
|
this.logger.error(`File does not exist: ${fileName}`);
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
this.createFolderIfNotExist(folder);
|
|
20
|
-
const
|
|
20
|
+
const newFileName = newName ?? this.pathManager.getFileBasename(fileName);
|
|
21
|
+
const outputFileName = this.pathManager.changeDirectory(folder, newFileName);
|
|
21
22
|
this.fileHandler.copyFile(fileName, outputFileName);
|
|
22
23
|
}
|
|
23
|
-
copyFileToFolderOrSkip(fileName, folder) {
|
|
24
|
+
copyFileToFolderOrSkip(fileName, folder, newName) {
|
|
24
25
|
const fileBasename = this.pathManager.getFileBasename(fileName);
|
|
25
26
|
const outputFileName = this.pathManager.changeDirectory(folder, fileBasename);
|
|
26
27
|
if (this.fileHandler.verifyIfFileExists(outputFileName)) {
|
|
27
28
|
this.logger.log(`File ${fileBasename} already exists in ${folder}. Skipping...`);
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
if (newName) {
|
|
32
|
+
this.copyFileToFolder(fileName, folder, newName);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.copyFileToFolder(fileName, folder);
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
}
|
|
@@ -20,7 +20,7 @@ describe('FileCopier', () => {
|
|
|
20
20
|
fileCopier = new FileCopier(fileHandler, logger);
|
|
21
21
|
});
|
|
22
22
|
describe('copyFileToFolder', () => {
|
|
23
|
-
it('should copy files to folder', () => {
|
|
23
|
+
it('should copy files to folder with the same name', () => {
|
|
24
24
|
const file = faker.system.filePath();
|
|
25
25
|
const folder = faker.system.directoryPath();
|
|
26
26
|
const outputFileName = join(folder, basename(file));
|
|
@@ -28,6 +28,14 @@ describe('FileCopier', () => {
|
|
|
28
28
|
fileCopier.copyFileToFolder(file, folder);
|
|
29
29
|
expect(fileHandler.copyFile).toHaveBeenCalledWith(file, outputFileName);
|
|
30
30
|
});
|
|
31
|
+
it('should copy files to folder with the given name', () => {
|
|
32
|
+
const file = faker.system.filePath();
|
|
33
|
+
const folder = faker.system.directoryPath();
|
|
34
|
+
const outputFileName = basename(faker.system.filePath());
|
|
35
|
+
fileHandler.verifyIfFileExists.mockReturnValue(true);
|
|
36
|
+
fileCopier.copyFileToFolder(file, folder, outputFileName);
|
|
37
|
+
expect(fileHandler.copyFile).toHaveBeenCalledWith(file, join(folder, outputFileName));
|
|
38
|
+
});
|
|
31
39
|
it('should call logger.error if file does not exist', () => {
|
|
32
40
|
fileHandler.verifyIfFileExists.mockReturnValue(false);
|
|
33
41
|
fileCopier.copyFileToFolder('dummy', 'dummy');
|
package/dist/domain/helpers.js
CHANGED
|
@@ -18,8 +18,8 @@ export const configureHusky = () => {
|
|
|
18
18
|
export const copyConfigurationFiles = () => {
|
|
19
19
|
logger.log('Copying configuration files...');
|
|
20
20
|
const templatesDirectory = packageManager.getTemplatesFolderPath();
|
|
21
|
-
devDepFiles.forEach((
|
|
22
|
-
logger.log(`Copying file ${
|
|
23
|
-
fileCopier.copyFileToFolderOrSkip(pathManager.changeDirectory(templatesDirectory,
|
|
21
|
+
devDepFiles.forEach(({ sourceName, targetName }) => {
|
|
22
|
+
logger.log(`Copying file ${sourceName} as ${targetName}...`);
|
|
23
|
+
fileCopier.copyFileToFolderOrSkip(pathManager.changeDirectory(templatesDirectory, sourceName), cwd, targetName);
|
|
24
24
|
});
|
|
25
25
|
};
|
package/dist/wires/constants.js
CHANGED
|
@@ -23,6 +23,10 @@ export const devDeps = [
|
|
|
23
23
|
name: 'eslint-config-prettier',
|
|
24
24
|
version: '10.1.8',
|
|
25
25
|
},
|
|
26
|
+
{
|
|
27
|
+
name: 'eslint-plugin-prettier',
|
|
28
|
+
version: '5.2.2',
|
|
29
|
+
},
|
|
26
30
|
{
|
|
27
31
|
name: 'lint-staged',
|
|
28
32
|
version: '16.2.7',
|
|
@@ -37,10 +41,26 @@ export const devDeps = [
|
|
|
37
41
|
},
|
|
38
42
|
];
|
|
39
43
|
export const devDepFiles = [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
{
|
|
45
|
+
sourceName: 'template.eslint.config.js',
|
|
46
|
+
targetName: 'eslint.config.js',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
sourceName: 'template.prettier.config.js',
|
|
50
|
+
targetName: 'prettier.config.js',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
sourceName: 'template.lint-staged.config.js',
|
|
54
|
+
targetName: 'lint-staged.config.js',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
sourceName: 'template.tsconfig.json',
|
|
58
|
+
targetName: 'tsconfig.json',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
sourceName: 'template.tsconfig.build.json',
|
|
62
|
+
targetName: 'tsconfig.build.json',
|
|
63
|
+
},
|
|
44
64
|
];
|
|
45
65
|
export const initHusky = 'npx husky init';
|
|
46
66
|
export const prepareHusky = 'npm run prepare';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mateoserrano/simple-config",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Initialize ESLint, Prettier, Husky and lint-staged for modern TypeScript projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Mateo Serrano (https://github.com/Mateo-Serrano-24504)",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"dist/",
|
|
27
27
|
"templates/",
|
|
28
28
|
"README.md",
|
|
29
|
-
"LICENSE"
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"CHANGELOG.md"
|
|
30
31
|
],
|
|
31
32
|
"bin": {
|
|
32
33
|
"dev-config": "dist/scripts/init.js"
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
"@types/node": "25.0.3",
|
|
41
42
|
"eslint": "9.39.1",
|
|
42
43
|
"eslint-config-prettier": "10.1.8",
|
|
44
|
+
"eslint-plugin-prettier": "5.2.2",
|
|
43
45
|
"globals": "17.0.0",
|
|
44
46
|
"husky": "9.1.7",
|
|
45
47
|
"lint-staged": "16.2.7",
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import eslint from '@eslint/js';
|
|
3
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
4
|
+
import globals from 'globals';
|
|
5
|
+
import tseslint from 'typescript-eslint';
|
|
6
|
+
|
|
7
|
+
export default tseslint.config(
|
|
8
|
+
{
|
|
9
|
+
ignores: [
|
|
10
|
+
'dist/**',
|
|
11
|
+
'node_modules/**',
|
|
12
|
+
'**/eslint.config.js',
|
|
13
|
+
'**/prettier.config.js',
|
|
14
|
+
'**/lint-staged.config.js',
|
|
15
|
+
'**/tsconfig.build.json',
|
|
16
|
+
'**/tsconfig.json',
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
eslint.configs.recommended,
|
|
20
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
21
|
+
eslintPluginPrettierRecommended,
|
|
22
|
+
{
|
|
23
|
+
languageOptions: {
|
|
24
|
+
globals: {
|
|
25
|
+
...globals.node,
|
|
26
|
+
},
|
|
27
|
+
sourceType: 'module',
|
|
28
|
+
parserOptions: {
|
|
29
|
+
ecmaVersion: 'latest',
|
|
30
|
+
project: './tsconfig.json',
|
|
31
|
+
tsconfigRootDir: import.meta.dirname,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
|
|
37
|
+
languageOptions: {
|
|
38
|
+
sourceType: 'script',
|
|
39
|
+
},
|
|
40
|
+
rules: {
|
|
41
|
+
...tseslint.configs.disableTypeChecked.rules,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
rules: {
|
|
46
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
47
|
+
'@typescript-eslint/no-floating-promises': 'warn',
|
|
48
|
+
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
49
|
+
'prettier/prettier': ['error', { endOfLine: 'auto' }],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"rootDir": "src",
|
|
9
|
+
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
|
|
13
|
+
"strict": true,
|
|
14
|
+
"noImplicitOverride": true,
|
|
15
|
+
"noUncheckedIndexedAccess": true,
|
|
16
|
+
"exactOptionalPropertyTypes": true,
|
|
17
|
+
"useUnknownInCatchVariables": true,
|
|
18
|
+
|
|
19
|
+
"forceConsistentCasingInFileNames": true,
|
|
20
|
+
"skipLibCheck": true
|
|
21
|
+
},
|
|
22
|
+
"include": ["src/**/*.ts"],
|
|
23
|
+
"exclude": ["src/**/*.spec.ts"]
|
|
24
|
+
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import js from '@eslint/js'
|
|
2
|
-
import globals from 'globals'
|
|
3
|
-
import tseslint from 'typescript-eslint'
|
|
4
|
-
|
|
5
|
-
export default tseslint.config([
|
|
6
|
-
js.configs.recommended,
|
|
7
|
-
...tseslint.configs.recommended,
|
|
8
|
-
{
|
|
9
|
-
ignores: ['dist/**'],
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
files: ['**/*.ts'],
|
|
13
|
-
languageOptions: {
|
|
14
|
-
parser: tseslint.parser,
|
|
15
|
-
parserOptions: {
|
|
16
|
-
ecmaVersion: 'latest',
|
|
17
|
-
sourceType: 'module',
|
|
18
|
-
},
|
|
19
|
-
globals: {
|
|
20
|
-
...globals.node,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
plugins: {
|
|
24
|
-
'@typescript-eslint': tseslint.plugin,
|
|
25
|
-
},
|
|
26
|
-
rules: {
|
|
27
|
-
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
28
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
29
|
-
'@typescript-eslint/consistent-type-imports': 'warn',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
files: ['**/*.js'],
|
|
34
|
-
languageOptions: {
|
|
35
|
-
sourceType: 'module',
|
|
36
|
-
globals: globals.node,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
])
|
|
File without changes
|