ts-builds 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/dist/cli.js +27 -17
- package/package.json +7 -8
- package/templates/npmrc +0 -7
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
4
|
import { createInterface } from "node:readline";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
5
|
|
|
7
6
|
//#region src/cli.ts
|
|
8
|
-
const templateDir = join(dirname(fileURLToPath(import.meta.url)), "..", "templates");
|
|
9
7
|
const targetDir = process.cwd();
|
|
10
8
|
const bundledPackages = [
|
|
11
9
|
"@eslint/eslintrc",
|
|
@@ -26,10 +24,30 @@ const bundledPackages = [
|
|
|
26
24
|
"typescript",
|
|
27
25
|
"vitest"
|
|
28
26
|
];
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const requiredHoistPatterns = [
|
|
28
|
+
"public-hoist-pattern[]=*eslint*",
|
|
29
|
+
"public-hoist-pattern[]=*prettier*",
|
|
30
|
+
"public-hoist-pattern[]=*vitest*",
|
|
31
|
+
"public-hoist-pattern[]=typescript",
|
|
32
|
+
"public-hoist-pattern[]=*rimraf*",
|
|
33
|
+
"public-hoist-pattern[]=*cross-env*"
|
|
34
|
+
];
|
|
35
|
+
function ensureNpmrcHoistPatterns() {
|
|
36
|
+
const npmrcPath = join(targetDir, ".npmrc");
|
|
37
|
+
const existingContent = existsSync(npmrcPath) ? readFileSync(npmrcPath, "utf-8") : "";
|
|
38
|
+
const missingPatterns = requiredHoistPatterns.filter((pattern) => !existingContent.includes(pattern));
|
|
39
|
+
if (missingPatterns.length === 0) return;
|
|
40
|
+
const header = "# Hoist CLI tool binaries from peer dependencies";
|
|
41
|
+
const hasHeader = existingContent.includes(header);
|
|
42
|
+
let newContent = existingContent;
|
|
43
|
+
if (!hasHeader && missingPatterns.length > 0) newContent = existingContent + (existingContent.length > 0 && !existingContent.endsWith("\n") ? "\n\n" : existingContent.length > 0 ? "\n" : "") + header + "\n";
|
|
44
|
+
for (const pattern of missingPatterns) {
|
|
45
|
+
if (!newContent.endsWith("\n") && newContent.length > 0) newContent += "\n";
|
|
46
|
+
newContent += pattern + "\n";
|
|
47
|
+
}
|
|
48
|
+
writeFileSync(npmrcPath, newContent);
|
|
49
|
+
console.log(`✓ Updated .npmrc with ${missingPatterns.length} missing hoist pattern(s)`);
|
|
50
|
+
}
|
|
33
51
|
function showHelp() {
|
|
34
52
|
console.log(`
|
|
35
53
|
ts-builds - Shared TypeScript configuration files
|
|
@@ -130,15 +148,7 @@ async function cleanup() {
|
|
|
130
148
|
}
|
|
131
149
|
function init() {
|
|
132
150
|
console.log("Initializing ts-builds...");
|
|
133
|
-
|
|
134
|
-
const src = join(templateDir, srcFile);
|
|
135
|
-
const dest = join(targetDir, destFile);
|
|
136
|
-
if (existsSync(dest)) console.log(` ⚠ ${destFile} already exists, skipping`);
|
|
137
|
-
else {
|
|
138
|
-
copyFileSync(src, dest);
|
|
139
|
-
console.log(` ✓ Created ${destFile}`);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
151
|
+
ensureNpmrcHoistPatterns();
|
|
142
152
|
console.log("\nDone! Your project is configured to hoist CLI binaries from peer dependencies.");
|
|
143
153
|
console.log("\nNext steps:");
|
|
144
154
|
console.log(" - Run 'npx ts-builds info' to see bundled packages");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-builds",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Shared TypeScript configuration files for library templates. Provides standardized ESLint, Prettier, Vitest, TypeScript, and build configs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"./package.json": "./package.json"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
|
-
"templates",
|
|
40
39
|
"prettier-config.js",
|
|
41
40
|
".prettierignore",
|
|
42
41
|
"eslint.config.base.mjs",
|
|
@@ -51,10 +50,10 @@
|
|
|
51
50
|
"@eslint/eslintrc": "^3.3.3",
|
|
52
51
|
"@eslint/js": "^9.39.1",
|
|
53
52
|
"@types/node": "^22.19.1",
|
|
54
|
-
"@typescript-eslint/eslint-plugin": "^8.48.
|
|
55
|
-
"@typescript-eslint/parser": "^8.48.
|
|
56
|
-
"@vitest/coverage-v8": "^4.0.
|
|
57
|
-
"@vitest/ui": "^4.0.
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^8.48.1",
|
|
54
|
+
"@typescript-eslint/parser": "^8.48.1",
|
|
55
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
56
|
+
"@vitest/ui": "^4.0.15",
|
|
58
57
|
"cross-env": "^10.1.0",
|
|
59
58
|
"eslint": "^9.39.1",
|
|
60
59
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -62,11 +61,11 @@
|
|
|
62
61
|
"eslint-plugin-prettier": "^5.5.4",
|
|
63
62
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
64
63
|
"globals": "^16.5.0",
|
|
65
|
-
"prettier": "^3.7.
|
|
64
|
+
"prettier": "^3.7.4",
|
|
66
65
|
"rimraf": "^6.1.2",
|
|
67
66
|
"ts-node": "^10.9.2",
|
|
68
67
|
"typescript": "^5.9.3",
|
|
69
|
-
"vitest": "^4.0.
|
|
68
|
+
"vitest": "^4.0.15"
|
|
70
69
|
},
|
|
71
70
|
"devDependencies": {
|
|
72
71
|
"tsdown": "^0.16.8"
|
package/templates/npmrc
DELETED