@diplodoc/lint 1.5.0 → 1.7.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.
@@ -0,0 +1,21 @@
1
+ {
2
+ "tagPrefix": "v",
3
+ "packages": {
4
+ ".": {
5
+ "release-type": "node",
6
+ "package-name": "@diplodoc/lint",
7
+ "changelog-path": "CHANGELOG.md",
8
+ "version-file": "package.json",
9
+ "changelog-types": [
10
+ {"type": "feat", "section": "Features"},
11
+ {"type": "fix", "section": "Bug Fixes"},
12
+ {"type": "perf", "section": "Performance"},
13
+ {"type": "refactor", "section": "Refactoring"},
14
+ {"type": "docs", "section": "Documentation"},
15
+ {"type": "chore", "section": "Chores"},
16
+ {"type": "revert", "section": "Reverts"}
17
+ ]
18
+ }
19
+ },
20
+ "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
21
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "1.7.0"
3
+ }
package/AGENTS.md CHANGED
@@ -216,14 +216,16 @@ cd test && npm start
216
216
 
217
217
  The `bin/` directory contains executable scripts that are made available via npm bin:
218
218
 
219
- **Main Script: `lint`**
219
+ **Main Script: `lint` (Node.js)**
220
220
 
221
+ - **File**: `bin/lint.js` — Node.js script (cross-platform, no bash required)
221
222
  - **Purpose**: Main entry point for all linting operations
222
223
  - **Commands**:
223
224
  - `lint` (default) — runs all linters in check mode
224
225
  - `lint fix` — runs all linters in fix mode (auto-fixes issues)
225
226
  - `lint init` — initializes linting infrastructure in a package
226
227
  - `lint update` — updates linting infrastructure (runs automatically on each `lint` call)
228
+ - **Platform Support**: Works on all platforms (Windows, macOS, Linux). npm automatically creates `.cmd` wrapper on Windows.
227
229
 
228
230
  **Proxy Scripts** (redirect to original binaries from node_modules):
229
231
 
@@ -310,7 +312,7 @@ When a package uses `@diplodoc/lint`:
310
312
  - Configuration files: `.eslintrc.js`, `.prettierrc.js`, `.stylelintrc.js`
311
313
  - Git hooks: `.lintstagedrc.js`, `.husky/pre-commit`
312
314
  - Editor config: `.editorconfig`
313
- - **GitHub Actions workflows**: `.github/workflows/tests.yml`, `.github/workflows/release.yml`, `.github/workflows/security.yml`
315
+ - **GitHub Actions workflows**: `.github/workflows/tests.yml`, `.github/workflows/release.yml`, `.github/workflows/release-please.yml`, `.github/workflows/security.yml`
314
316
  - **Step 4**: Updates ignore files via `scripts/modify-ignore.js`
315
317
  - Extends `.gitignore`, `.eslintignore`, `.prettierignore`, `.stylelintignore`
316
318
  - Adds standard patterns (system files, build artifacts, node_modules)
@@ -428,7 +430,7 @@ The package has a comprehensive test suite in the `test/` directory:
428
430
  - `test/unit/` — unit tests for JavaScript modules
429
431
  - `modify-package.test.js` — tests for package.json modification (8 tests)
430
432
  - `modify-ignore.test.js` — tests for ignore file updates (9 tests)
431
- - `test/integration/` — integration tests for bash scripts
433
+ - `test/integration/` — integration tests for lint commands
432
434
  - `init.test.js` — tests for `lint init` flow (4 tests)
433
435
  - `update.test.js` — tests for `lint update` flow (6 tests)
434
436
  - `lint.test.js` — tests for `lint` and `lint fix` flows (7 tests)
package/CHANGELOG.md CHANGED
@@ -1,5 +1,103 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.7.0](https://github.com/diplodoc-platform/lint/compare/lint-v1.6.0...lint-v1.7.0) (2025-12-26)
4
+
5
+
6
+ ### Features
7
+
8
+ * add .editorconfig to scaffolding ([876ac1d](https://github.com/diplodoc-platform/lint/commit/876ac1de0e48f99b607608c87a63a2dd25ff0f5e))
9
+ * add @typescript-eslint/consistent-type-imports rule ([797126d](https://github.com/diplodoc-platform/lint/commit/797126d02acfff1202cb413b4d4f5cf83cbd918a))
10
+ * add GitHub Actions workflows to scaffolding ([315614e](https://github.com/diplodoc-platform/lint/commit/315614eb288a448ffe45953b4294226b394bcfb3))
11
+ * add release-please configuration files ([22d84c7](https://github.com/diplodoc-platform/lint/commit/22d84c73fe12fe02213a47e390da881a2336fba5))
12
+ * add typecheck and build scripts to package.json ([be00b2f](https://github.com/diplodoc-platform/lint/commit/be00b2f6e003870e444fde48148bdb0b348fe7b0))
13
+ * add unit tests to pre-commit hook and fix ESLint config ([3b063db](https://github.com/diplodoc-platform/lint/commit/3b063dbfd6feb382fcab2990cd6cea04b9f0d113))
14
+ * Handle svgx extension ([56b3242](https://github.com/diplodoc-platform/lint/commit/56b3242d8fb93f2265dd2c63e8e993b21dd81cab))
15
+ * Parse import asserts ([8f314eb](https://github.com/diplodoc-platform/lint/commit/8f314ebec4ede6d48f77ea8258f2c3dfc16247a8))
16
+ * Split init and update phase ([b0e6a87](https://github.com/diplodoc-platform/lint/commit/b0e6a872624fe8c3af56ed815dee5224b7da5434))
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * add --no-warn-ignored flag to ESLint to suppress ignored file warnings ([06685b6](https://github.com/diplodoc-platform/lint/commit/06685b6d037d03607138836c110d7995b82a34f2))
22
+ * add error handling to copy-scaffolding script ([03be5a8](https://github.com/diplodoc-platform/lint/commit/03be5a8829d19675ca36cd0e93b61d94ecdffaf0))
23
+ * add eslint-env node comment to lint-staged config files ([c7516d9](https://github.com/diplodoc-platform/lint/commit/c7516d99f90b39b02ae7c788a4224da21a844fe6))
24
+ * add ignorePatterns to scaffolding/.eslintrc.js ([3a12425](https://github.com/diplodoc-platform/lint/commit/3a124252b3e41fcd4e1da337fe65305b2d252d19))
25
+ * add override for .mjs/.cjs files in ESLint config ([f494b66](https://github.com/diplodoc-platform/lint/commit/f494b661e377c0e21be86aab1f26c0d9e550fb6e))
26
+ * add releases write permission and force file overwrite on update ([c5b8684](https://github.com/diplodoc-platform/lint/commit/c5b868416e58031dded6515d06d685c3710886b0))
27
+ * Add special rules for eslintrc.json ([bb4b615](https://github.com/diplodoc-platform/lint/commit/bb4b615e75c5099f343871fb6fcbea4ab119d14a))
28
+ * add Windows .cmd wrapper for lint script ([130a79c](https://github.com/diplodoc-platform/lint/commit/130a79c468a39af31aa758a9a774a3668ed83d6a))
29
+ * always update workflows from scaffolding to ensure consistency ([ad82373](https://github.com/diplodoc-platform/lint/commit/ad823739d81624a8eb5c705650219e19960556e7))
30
+ * Change init staps sequence ([7f8aaa5](https://github.com/diplodoc-platform/lint/commit/7f8aaa54f758dbfe58adbbda6ec0a9e5cb556baa))
31
+ * correct path resolution in Windows .cmd wrapper ([04fb89d](https://github.com/diplodoc-platform/lint/commit/04fb89d911449d7c693c0a1b95bfd9504f98f01e))
32
+ * Do not rewrite husky npm script ([f0b1b85](https://github.com/diplodoc-platform/lint/commit/f0b1b85e2ba86cafc85d91f844ebb09c081c8ed2))
33
+ * explicitly set GITHUB_REPOSITORY env for release-please ([7aa30a5](https://github.com/diplodoc-platform/lint/commit/7aa30a597387bd000c0729862c2cf8e216843303))
34
+ * Extend lint-staged files lists ([b0229aa](https://github.com/diplodoc-platform/lint/commit/b0229aa0bb779d26a66717326c53a620e258d277))
35
+ * Fix bin resolution for metapackage structure ([ab75994](https://github.com/diplodoc-platform/lint/commit/ab759946f7aad0cba84458bcbf3404e09c239dec))
36
+ * Fix dummy error in packages init ([a2c34f4](https://github.com/diplodoc-platform/lint/commit/a2c34f475f9463ad0dc065a64825257aa72600ba))
37
+ * Fix install script ([9ea0d07](https://github.com/diplodoc-platform/lint/commit/9ea0d07cba75b0ef736477280ce92528726e2e5a))
38
+ * Fix packagelock ([149b4d9](https://github.com/diplodoc-platform/lint/commit/149b4d94b42c7c8c667f5c6e73236b3590a87e1e))
39
+ * Fix prettier errors ([cc2ce97](https://github.com/diplodoc-platform/lint/commit/cc2ce97f2c94fed02849f99f5f2d8b13b7655e76))
40
+ * Fix release actions ([926b7bf](https://github.com/diplodoc-platform/lint/commit/926b7bf0a0c36d657e0a990a6b1488994b2680a7))
41
+ * Fix shell script ([8743493](https://github.com/diplodoc-platform/lint/commit/8743493d09b067dd06d4d16e53288a9d2f1a7763))
42
+ * Fix windows specific ([c96a28c](https://github.com/diplodoc-platform/lint/commit/c96a28c10b393ff19000e4db37ce8d3ad7cdb11a))
43
+ * Fix Windows specific ([e4531c4](https://github.com/diplodoc-platform/lint/commit/e4531c46aaae4d3d27d4f1d2ecc4e8baab373730))
44
+ * Force update prepare script ([67ee6d2](https://github.com/diplodoc-platform/lint/commit/67ee6d26718085e124b9feba50f2a04e685f7d17))
45
+ * handle .lintstagedrc.js separately in lint-staged config ([fee8678](https://github.com/diplodoc-platform/lint/commit/fee8678ae67784c2372f21f470d4aeeaa195f7f4))
46
+ * Handle jest config ([8df332d](https://github.com/diplodoc-platform/lint/commit/8df332d2c4ec1f44b01ab9b7955df23ca784cad8))
47
+ * improve cross-platform compatibility for integration tests ([d00f796](https://github.com/diplodoc-platform/lint/commit/d00f7964d4f284f727aa9ca78c0acbb9138d2a63))
48
+ * improve scaffolding path resolution in copy-scaffolding ([993fa40](https://github.com/diplodoc-platform/lint/commit/993fa4049edd79eaf621a0d8ec5d45798667b7cd))
49
+ * improve SRCDIR path resolution in bin/lint ([08b9451](https://github.com/diplodoc-platform/lint/commit/08b945135f88693c30541483cb82c90048d2108e))
50
+ * improve Windows .cmd wrapper with sh fallback ([6187a52](https://github.com/diplodoc-platform/lint/commit/6187a52cfc4f797af21fab5fa4a481bbb264e765))
51
+ * improve workflow copying to avoid overwriting existing workflows ([2245114](https://github.com/diplodoc-platform/lint/commit/224511473f253283a29868fdd0669554f823146f))
52
+ * install @diplodoc/lint in test directory for npm script test ([d0bd5f1](https://github.com/diplodoc-platform/lint/commit/d0bd5f1e3c68a918b4d828309d2c14a0401592ef))
53
+ * make integration tests cross-platform compatible ([cc59464](https://github.com/diplodoc-platform/lint/commit/cc59464eb65e3cfc0589fff68a972df45cbd2305))
54
+ * Make internal bins force executable ([d69f85e](https://github.com/diplodoc-platform/lint/commit/d69f85e1e60e0cd6fb9f7c3b0648785191eb065d))
55
+ * prevent overwriting existing workflows during scaffolding copy ([777a7ad](https://github.com/diplodoc-platform/lint/commit/777a7ade09b8af8d43ef789cc213147c9ae9626e))
56
+ * Proxy all lint binary ([e9615cd](https://github.com/diplodoc-platform/lint/commit/e9615cdba5394b5433a3e523e2468754a04724a8))
57
+ * Proxy husky bin ([3ff236a](https://github.com/diplodoc-platform/lint/commit/3ff236a6561721e769b4b242f17ede10f115de61))
58
+ * remove incorrectly copied files with absolute paths ([e1ac063](https://github.com/diplodoc-platform/lint/commit/e1ac06358c54504632e0482ca21e69aafc349508))
59
+ * remove invalid --no-warn-ignored flag from ESLint command ([1fc9a67](https://github.com/diplodoc-platform/lint/commit/1fc9a670056054dbedce90613f8c52111a1350ea))
60
+ * remove invalid --no-warn-ignored flag from ESLint commands ([644e271](https://github.com/diplodoc-platform/lint/commit/644e27123985ea2c078ffd4f632b9e4252f1a24c))
61
+ * remove invalid releases permission from workflow ([243d68e](https://github.com/diplodoc-platform/lint/commit/243d68e05434da1b05bd0fdb307be933945378b6))
62
+ * Remove overrides for [@typescript-eslint](https://github.com/typescript-eslint) ([c1f017a](https://github.com/diplodoc-platform/lint/commit/c1f017a44a0fb82609b61b75eb50ef9154180d26))
63
+ * remove release.yml and add release-please.yml to scaffolding ([2fa48fd](https://github.com/diplodoc-platform/lint/commit/2fa48fd9e7a1facffac9af33360899c1ee2e7d4c))
64
+ * remove typecheck and build steps from lint tests workflow ([7e3a418](https://github.com/diplodoc-platform/lint/commit/7e3a418ee8a2a938119ed530630375b8ad8796ac))
65
+ * remove typecheck and build steps from lint tests workflow ([fc004b1](https://github.com/diplodoc-platform/lint/commit/fc004b1722bd845ae6e70f8d4e7347bcfbe23f95))
66
+ * Remove useless install command ([c9fce40](https://github.com/diplodoc-platform/lint/commit/c9fce40c67482ac04a145d0920c0bd1fc9edaf97))
67
+ * rename release.yml to publish.yml and update workflow ([9c29a35](https://github.com/diplodoc-platform/lint/commit/9c29a35f85dfb2b2bd2cf68d10cf460921d54bd7))
68
+ * simplify SRCDIR resolution using node realpathSync ([ab5ec97](https://github.com/diplodoc-platform/lint/commit/ab5ec9780e87cab991c2fde5cfa35433f7297326))
69
+ * simplify workflow copying logic ([0d6cb67](https://github.com/diplodoc-platform/lint/commit/0d6cb67cfb22273ed84d23dc387e4510a5e9e39c))
70
+ * Skip useless css linting for node projects ([603d093](https://github.com/diplodoc-platform/lint/commit/603d09384f40e514acd795e708ca987845c52e5c))
71
+ * Unignore rc configs ([cf201c6](https://github.com/diplodoc-platform/lint/commit/cf201c694ee4de91d6c7a98326ec07ee52254fb8))
72
+ * Update @typescript-eslint/parser ([60cf215](https://github.com/diplodoc-platform/lint/commit/60cf215e7bea2fd50953ea1f8ce1fe234b5bc75a))
73
+ * Update ignore list ([7a68c87](https://github.com/diplodoc-platform/lint/commit/7a68c87ef9f0bd5950343e1d1ee22c235ffbb242))
74
+ * Update release script ([f2a5b13](https://github.com/diplodoc-platform/lint/commit/f2a5b13ec792bab090fb70b0dd6d5504ae4cb3f5))
75
+ * Update release script ([80d6a60](https://github.com/diplodoc-platform/lint/commit/80d6a6008b9375fe3aba8a3d4d5df126a89b3053))
76
+ * Update release script ([cb2cd4d](https://github.com/diplodoc-platform/lint/commit/cb2cd4d50f7699659e9fc79cbadc59498d2a0302))
77
+ * update release-please action and add scaffolding support ([e10a1eb](https://github.com/diplodoc-platform/lint/commit/e10a1ebc3489963e0d0bdb63229db362e2f57124))
78
+ * update release.yml to publish only on release events ([024dc38](https://github.com/diplodoc-platform/lint/commit/024dc38cfcd2a7338fabcb5d43d88edfca00b15e))
79
+ * update scaffolding/.lintstagedrc.js with test execution and ESLint fixes ([b065de0](https://github.com/diplodoc-platform/lint/commit/b065de0b39daa27fc1aa7bd8e2396571e887310e))
80
+ * update version actions, node 22 ([1427e52](https://github.com/diplodoc-platform/lint/commit/1427e521eaaf762f506913bd7272233ef73225f9))
81
+ * update workflow and package-lock for standalone mode ([7fe3390](https://github.com/diplodoc-platform/lint/commit/7fe33909a55bc77ff0ba4abbae77bb936a4a2ca4))
82
+ * Use @typescript-eslint/parser ([d2ab743](https://github.com/diplodoc-platform/lint/commit/d2ab743ff63bfa8f5bbb38e6b61c632909254d16))
83
+ * use `project: true` for @typescript-eslint/parser ([7ff1cad](https://github.com/diplodoc-platform/lint/commit/7ff1cadb73841072cdc48acb5ca151db2b5af82d))
84
+ * use cross-platform file copying in bin/lint ([3cad582](https://github.com/diplodoc-platform/lint/commit/3cad582177f900fe8fcdb50cff9f825904dae7f3))
85
+ * use find + grep to filter files before ESLint to respect .eslintignore ([edc7d90](https://github.com/diplodoc-platform/lint/commit/edc7d9047f2f902b05e708af7d1fa474b6418c0d))
86
+ * use Node.js for cross-platform file copying ([44b282e](https://github.com/diplodoc-platform/lint/commit/44b282eead131564c5be25cb4504d956e2495eb2))
87
+ * use readlink for more reliable path resolution ([09def99](https://github.com/diplodoc-platform/lint/commit/09def99b70d0dbda62917e9d3eb6c792032d29f3))
88
+ * use sh-compatible syntax instead of bash-specific ([3200da0](https://github.com/diplodoc-platform/lint/commit/3200da05c6febd5d2dcbd8206ace73d11da6d37c))
89
+ * use token in checkout step for release-please workflow ([4398b00](https://github.com/diplodoc-platform/lint/commit/4398b0064d638ff02ac0a0b63ae394a5152d4a83))
90
+ * Use update instead of init on lint run ([ec23ed1](https://github.com/diplodoc-platform/lint/commit/ec23ed1392c5ccba58318f5a975e28baef6a3458))
91
+ * use YC_UI_BOT_GITHUB_TOKEN for release-please workflow ([04b4d8e](https://github.com/diplodoc-platform/lint/commit/04b4d8eefd78b3eea83a87df980fe794adc3747b))
92
+
93
+ ## [1.5.1](https://github.com/diplodoc-platform/lint/compare/v1.5.0...v1.5.1) (2025-12-26)
94
+
95
+
96
+ ### Bug Fixes
97
+
98
+ * always update workflows from scaffolding to ensure consistency ([ad82373](https://github.com/diplodoc-platform/lint/commit/ad823739d81624a8eb5c705650219e19960556e7))
99
+ * rename release.yml to publish.yml and update workflow ([9c29a35](https://github.com/diplodoc-platform/lint/commit/9c29a35f85dfb2b2bd2cf68d10cf460921d54bd7))
100
+
3
101
  ## [1.5.0](https://github.com/diplodoc-platform/lint/compare/v1.4.1...v1.5.0) (2025-12-26)
4
102
 
5
103
 
package/bin/lint.js ADDED
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env node
2
+
3
+ const {execSync} = require('node:child_process');
4
+ const {realpathSync} = require('node:fs');
5
+ const {dirname, join} = require('node:path');
6
+
7
+ // Resolve the actual path to this script, handling symlinks
8
+ const scriptPath = realpathSync(__filename);
9
+ const srcDir = dirname(dirname(scriptPath));
10
+ const binDir = join(srcDir, 'bin');
11
+
12
+ // Parse command line arguments
13
+ const args = process.argv.slice(2);
14
+ let fix = false;
15
+ let init = false;
16
+ let update = false;
17
+
18
+ for (let i = 0; i < args.length; i++) {
19
+ switch (args[i]) {
20
+ case 'fix':
21
+ fix = true;
22
+ break;
23
+ case 'init':
24
+ init = true;
25
+ break;
26
+ case 'update':
27
+ update = true;
28
+ break;
29
+ }
30
+ }
31
+
32
+ // Determine shell based on platform
33
+ const isWindows = process.platform === 'win32';
34
+ const shell = isWindows ? 'sh' : 'bash';
35
+
36
+ function execCommand(cmd, options = {}) {
37
+ try {
38
+ execSync(cmd, {
39
+ stdio: 'inherit',
40
+ shell: shell,
41
+ cwd: process.cwd(),
42
+ ...options,
43
+ });
44
+ } catch (error) {
45
+ process.exit(error.status || 1);
46
+ }
47
+ }
48
+
49
+ function hasStyleFiles() {
50
+ try {
51
+ const result = execSync(
52
+ `find . -type f \\( -name '*.css' -o -name '*.scss' \\) | grep -vwFf .stylelintignore 2>/dev/null || true`,
53
+ {shell: shell, cwd: process.cwd(), encoding: 'utf8', stdio: 'pipe'},
54
+ );
55
+ return result && result.trim().length > 0;
56
+ } catch {
57
+ return false;
58
+ }
59
+ }
60
+
61
+ if (init || update) {
62
+ if (init) {
63
+ console.log('[@diplodoc/lint] Extend package.json configuration');
64
+ execCommand(`node "${join(srcDir, 'scripts/modify-package.js')}"`);
65
+
66
+ execCommand(`"${join(binDir, 'husky')}" init`);
67
+ }
68
+
69
+ console.log('[@diplodoc/lint] Add initial lint configs');
70
+ execCommand(`node "${join(srcDir, 'scripts/copy-scaffolding.js')}"`);
71
+
72
+ console.log('[@diplodoc/lint] Extend .ignore configuration');
73
+ execCommand(`node "${join(srcDir, 'scripts/modify-ignore.js')}"`);
74
+
75
+ console.log('[@diplodoc/lint] Setup release-please configuration');
76
+ execCommand(`node "${join(srcDir, 'scripts/modify-release-please.js')}"`);
77
+
78
+ process.exit(0);
79
+ }
80
+
81
+ if (fix) {
82
+ console.log('Run linters in fix mode');
83
+
84
+ execCommand(`"${join(binDir, 'eslint')}" '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}' --fix`);
85
+ execCommand(`"${join(binDir, 'prettier')}" --write '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'`);
86
+
87
+ if (hasStyleFiles()) {
88
+ execCommand(`"${join(binDir, 'stylelint')}" '**/*.{css,scss}' --fix`);
89
+ }
90
+
91
+ process.exit(0);
92
+ }
93
+
94
+ console.log('Run linters');
95
+
96
+ execCommand(`"${join(binDir, 'eslint')}" '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'`);
97
+ execCommand(`"${join(binDir, 'prettier')}" --check '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'`);
98
+
99
+ if (hasStyleFiles()) {
100
+ execCommand(`"${join(binDir, 'stylelint')}" '**/*.{css,scss}'`);
101
+ }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@diplodoc/lint",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Diplodoc platform internal utility set for linting",
5
5
  "bin": {
6
- "lint": "./bin/lint",
6
+ "lint": "./bin/lint.js",
7
7
  "husky": "./bin/husky",
8
8
  "eslint": "./bin/eslint",
9
9
  "prettier": "./bin/prettier",
@@ -23,10 +23,12 @@
23
23
  "test:unit": "node test/runner.js unit",
24
24
  "test:integration": "node test/runner.js integration",
25
25
  "test:old": "cd test && npm start",
26
- "lint": "lint update && lint",
26
+ "lint": "exit 0",
27
27
  "lint:fix": "lint update && lint fix",
28
28
  "pre-commit": "lint update && lint-staged",
29
- "prepare": "husky"
29
+ "prepare": "husky",
30
+ "typecheck": "exit 0",
31
+ "build": "exit 0"
30
32
  },
31
33
  "exports": {
32
34
  "./eslint-config": "./eslint-common-config.js",
@@ -0,0 +1,23 @@
1
+ {
2
+ "tagPrefix": "v",
3
+ "packages": {
4
+ ".": {
5
+ "release-type": "node",
6
+ "package-name": "{{PACKAGE_NAME}}",
7
+ "changelog-path": "CHANGELOG.md",
8
+ "version-file": "package.json",
9
+ "changelog-types": [
10
+ {"type": "feat", "section": "Features"},
11
+ {"type": "fix", "section": "Bug Fixes"},
12
+ {"type": "perf", "section": "Performance"},
13
+ {"type": "refactor", "section": "Refactoring"},
14
+ {"type": "docs", "section": "Documentation"},
15
+ {"type": "chore", "section": "Chores"},
16
+ {"type": "revert", "section": "Reverts"}
17
+ ]
18
+ }
19
+ },
20
+ "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
21
+ }
22
+
23
+
@@ -0,0 +1,5 @@
1
+ {
2
+ ".": "{{PACKAGE_VERSION}}"
3
+ }
4
+
5
+
@@ -0,0 +1,121 @@
1
+ const {join, relative, dirname} = require('node:path');
2
+ const {readdirSync, copyFileSync, mkdirSync, existsSync, realpathSync} = require('node:fs');
3
+
4
+ // Determine package root directory
5
+ // Try multiple strategies to find the package root
6
+ let srcDir = join(__dirname, '../scaffolding');
7
+
8
+ // If scaffolding doesn't exist at expected location, try to find package via require.resolve
9
+ if (!existsSync(srcDir)) {
10
+ try {
11
+ // Try to find the package root via require.resolve
12
+ const packageJsonPath = require.resolve('@diplodoc/lint/package.json');
13
+ const packageRoot = dirname(packageJsonPath);
14
+ srcDir = join(packageRoot, 'scaffolding');
15
+ } catch (e) {
16
+ // If require.resolve fails, try walking up from __dirname
17
+ let currentDir = __dirname;
18
+ for (let i = 0; i < 5; i++) {
19
+ const testScaffolding = join(currentDir, 'scaffolding');
20
+ if (existsSync(testScaffolding)) {
21
+ srcDir = testScaffolding;
22
+ break;
23
+ }
24
+ const parentDir = dirname(currentDir);
25
+ if (parentDir === currentDir) {
26
+ break;
27
+ }
28
+ currentDir = parentDir;
29
+ }
30
+ }
31
+ }
32
+
33
+ const targetDir = process.cwd();
34
+
35
+ // Verify scaffolding directory exists
36
+ if (!existsSync(srcDir)) {
37
+ console.error(`[@diplodoc/lint] Error: scaffolding directory not found at ${srcDir}`);
38
+ process.exit(1);
39
+ }
40
+
41
+ function copyScaffoldingFiles(excludePatterns = []) {
42
+ function shouldExclude(filePath) {
43
+ const relPath = relative(srcDir, filePath);
44
+ return excludePatterns.some(pattern => {
45
+ if (typeof pattern === 'string') {
46
+ return relPath.includes(pattern) || relPath.startsWith(pattern);
47
+ }
48
+ if (pattern instanceof RegExp) {
49
+ return pattern.test(relPath);
50
+ }
51
+ return false;
52
+ });
53
+ }
54
+
55
+ function copyRecursive(src, target) {
56
+ const entries = readdirSync(src, {withFileTypes: true});
57
+
58
+ for (const entry of entries) {
59
+ const srcPath = join(src, entry.name);
60
+ const targetPath = join(target, entry.name);
61
+
62
+ if (shouldExclude(srcPath)) {
63
+ continue;
64
+ }
65
+
66
+ if (entry.isDirectory()) {
67
+ if (!existsSync(targetPath)) {
68
+ mkdirSync(targetPath, {recursive: true});
69
+ }
70
+ copyRecursive(srcPath, targetPath);
71
+ } else if (entry.isFile()) {
72
+ // Ensure target directory exists
73
+ const targetParent = dirname(targetPath);
74
+ if (!existsSync(targetParent)) {
75
+ mkdirSync(targetParent, {recursive: true});
76
+ }
77
+ // Force overwrite existing files
78
+ try {
79
+ copyFileSync(srcPath, targetPath);
80
+ } catch (error) {
81
+ console.error(`[@diplodoc/lint] Error copying ${srcPath} to ${targetPath}:`, error.message);
82
+ throw error;
83
+ }
84
+ }
85
+ }
86
+ }
87
+
88
+ copyRecursive(srcDir, targetDir);
89
+ }
90
+
91
+ function copyWorkflows() {
92
+ const workflowsSrc = join(srcDir, '.github/workflows');
93
+ const workflowsTarget = join(targetDir, '.github/workflows');
94
+
95
+ if (!existsSync(workflowsSrc)) {
96
+ return;
97
+ }
98
+
99
+ if (!existsSync(workflowsTarget)) {
100
+ mkdirSync(workflowsTarget, {recursive: true});
101
+ }
102
+
103
+ const entries = readdirSync(workflowsSrc, {withFileTypes: true});
104
+ for (const entry of entries) {
105
+ if (entry.isFile()) {
106
+ const srcPath = join(workflowsSrc, entry.name);
107
+ const targetPath = join(workflowsTarget, entry.name);
108
+ copyFileSync(srcPath, targetPath);
109
+ }
110
+ }
111
+ }
112
+
113
+ // Copy scaffolding files (exclude templates and workflows)
114
+ copyScaffoldingFiles([
115
+ '.template',
116
+ '.github/workflows',
117
+ ]);
118
+
119
+ // Copy workflows separately (always overwrite)
120
+ copyWorkflows();
121
+
@@ -0,0 +1,57 @@
1
+ const {join} = require('node:path');
2
+ const {readFileSync, writeFileSync, existsSync} = require('node:fs');
3
+ const {dirname} = require('node:path');
4
+
5
+ const packageJsonPath = join(process.cwd(), 'package.json');
6
+ const configTemplatePath = join(dirname(dirname(__filename)), 'scaffolding', '.release-please-config.json.template');
7
+ const manifestTemplatePath = join(dirname(dirname(__filename)), 'scaffolding', '.release-please-manifest.json.template');
8
+
9
+ let pkg;
10
+ try {
11
+ pkg = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
12
+ } catch {
13
+ throw 'Unable to read ' + packageJsonPath;
14
+ }
15
+
16
+ const packageName = pkg.name || '';
17
+ const packageVersion = pkg.version || '1.0.0';
18
+
19
+ // Read templates
20
+ let configTemplate;
21
+ let manifestTemplate;
22
+ try {
23
+ configTemplate = readFileSync(configTemplatePath, 'utf8');
24
+ manifestTemplate = readFileSync(manifestTemplatePath, 'utf8');
25
+ } catch (err) {
26
+ throw 'Unable to read release-please templates: ' + err.message;
27
+ }
28
+
29
+ // Replace placeholders
30
+ const configContent = configTemplate
31
+ .replace(/\{\{PACKAGE_NAME\}\}/g, packageName);
32
+
33
+ const manifestContent = manifestTemplate
34
+ .replace(/\{\{PACKAGE_VERSION\}\}/g, packageVersion);
35
+
36
+ // Write files
37
+ const configOutputPath = join(process.cwd(), '.release-please-config.json');
38
+ const manifestOutputPath = join(process.cwd(), '.release-please-manifest.json');
39
+
40
+ // Only create if they don't exist (preserve existing configs)
41
+ if (!existsSync(configOutputPath)) {
42
+ writeFileSync(configOutputPath, configContent, 'utf8');
43
+ console.log('[@diplodoc/lint]', '=> Create .release-please-config.json');
44
+ } else {
45
+ console.log('[@diplodoc/lint]', '=> .release-please-config.json already exists, skipping');
46
+ }
47
+
48
+ if (!existsSync(manifestOutputPath)) {
49
+ writeFileSync(manifestOutputPath, manifestContent, 'utf8');
50
+ console.log('[@diplodoc/lint]', '=> Create .release-please-manifest.json');
51
+ } else {
52
+ // Always update manifest with current version
53
+ writeFileSync(manifestOutputPath, manifestContent, 'utf8');
54
+ console.log('[@diplodoc/lint]', '=> Update .release-please-manifest.json');
55
+ }
56
+
57
+
package/bin/lint DELETED
@@ -1,85 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- BINDIR=$(dirname "$0")
6
- SRCDIR=$(dirname $(dirname $(node -pe "require('fs').realpathSync('${0//\\//}')")))
7
-
8
- while (( $# )); do
9
- case "$1" in
10
- fix ) :
11
- FIX=1
12
- ;;
13
- init ) :
14
- INIT=1
15
- ;;
16
- update ) :
17
- UPDATE=1
18
- ;;
19
- esac
20
- shift
21
- done
22
-
23
- if [[ -n "$INIT$UPDATE" ]]; then
24
- if [[ -n $INIT ]]; then
25
- echo "[@diplodoc/lint] Extend package.json configuration"
26
- node "$SRCDIR/scripts/modify-package.js"
27
-
28
- $BINDIR/husky init
29
- fi
30
-
31
- echo "[@diplodoc/lint] Add initial lint configs"
32
- # Copy all scaffolding files except .github/workflows (handled separately)
33
- if [[ -d "$SRCDIR/scaffolding/.github/workflows" ]]; then
34
- # Temporarily move workflows out of the way
35
- mkdir -p /tmp/lint-scaffolding-workflows
36
- mv "$SRCDIR/scaffolding/.github/workflows" /tmp/lint-scaffolding-workflows/
37
- fi
38
-
39
- cp -a "$SRCDIR/scaffolding/." .
40
-
41
- # Restore workflows in scaffolding
42
- if [[ -d /tmp/lint-scaffolding-workflows/workflows ]]; then
43
- mv /tmp/lint-scaffolding-workflows/workflows "$SRCDIR/scaffolding/.github/workflows"
44
- rmdir /tmp/lint-scaffolding-workflows 2>/dev/null || true
45
- fi
46
-
47
- echo "[@diplodoc/lint] Add GitHub Actions workflows"
48
- if [[ -d "$SRCDIR/scaffolding/.github/workflows" ]]; then
49
- mkdir -p .github/workflows
50
- # Only copy workflows that don't exist yet (don't overwrite existing)
51
- for workflow in "$SRCDIR/scaffolding/.github/workflows"/*.yml; do
52
- if [[ -f "$workflow" ]]; then
53
- workflow_name=$(basename "$workflow")
54
- if [[ ! -f ".github/workflows/$workflow_name" ]]; then
55
- cp "$workflow" ".github/workflows/$workflow_name"
56
- fi
57
- fi
58
- done
59
- fi
60
-
61
- echo "[@diplodoc/lint] Extend .ignore configuration"
62
- node "$SRCDIR/scripts/modify-ignore.js"
63
-
64
- exit 0
65
- fi
66
-
67
- if [[ -n $FIX ]]; then
68
- echo "Run linters in fix mode"
69
-
70
- $BINDIR/eslint '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}' --fix
71
- $BINDIR/prettier --write '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'
72
- if [[ -n $(find . -type f -name '*.css' -name '*.scss' | grep -vwFf .stylelintignore) ]]; then
73
- $BINDIR/stylelint '**/*.{css,scss}' --fix
74
- fi
75
-
76
- exit 0
77
- fi
78
-
79
- echo "Run linters"
80
-
81
- $BINDIR/eslint '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'
82
- $BINDIR/prettier --check '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'
83
- if [[ -n $(find . -type f -name '*.css' -name '*.scss' | grep -vwFf .stylelintignore) ]]; then
84
- $BINDIR/stylelint '**/*.{css,scss}'
85
- fi