vue-go-tsc 0.1.0 → 0.2.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 +3 -1
- package/install.js +44 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,10 +41,12 @@ See the full [CI integration guide](https://github.com/aidalinfo/vue-tsgo/blob/m
|
|
|
41
41
|
|
|
42
42
|
## Why vue-go-tsc?
|
|
43
43
|
|
|
44
|
-
-
|
|
44
|
+
- **~5–25× faster** than vue-tsc (project-dependent) — e.g. on the Pulse ERP
|
|
45
|
+
monorepo: app ~232s → **~49s** (~4.7×), docs site ~28s → **~1.5s** (~18×)
|
|
45
46
|
- **Lower memory usage** — native Go instead of Node.js
|
|
46
47
|
- **Drop-in replacement** for vue-tsc
|
|
47
48
|
- **Zero `.vue` file error delta** with vue-tsc on real-world projects
|
|
49
|
+
(verified 4 = 4 on Pulse ERP, 0 = 0 on its docs site)
|
|
48
50
|
|
|
49
51
|
## Documentation
|
|
50
52
|
|
package/install.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { existsSync, mkdirSync, chmodSync } = require('fs');
|
|
3
|
+
const { existsSync, mkdirSync, chmodSync, copyFileSync } = require('fs');
|
|
4
4
|
const { join } = require('path');
|
|
5
|
+
const os = require('os');
|
|
5
6
|
const https = require('https');
|
|
6
7
|
const { createWriteStream } = require('fs');
|
|
7
8
|
|
|
@@ -10,6 +11,12 @@ const BINARY_NAME = process.platform === 'win32' ? 'tsgo.exe' : 'tsgo';
|
|
|
10
11
|
const BIN_DIR = join(__dirname, 'bin');
|
|
11
12
|
const BIN_PATH = join(BIN_DIR, BINARY_NAME);
|
|
12
13
|
|
|
14
|
+
// Shared on-disk cache keyed by version + platform asset name. Lets CI restore
|
|
15
|
+
// the binary across runs (cache ~/.cache/vue-go-tsc) and avoids re-downloading
|
|
16
|
+
// on local reinstalls. Override the location with VUE_GO_TSC_CACHE_DIR.
|
|
17
|
+
const CACHE_ROOT = process.env.VUE_GO_TSC_CACHE_DIR || join(os.homedir(), '.cache', 'vue-go-tsc');
|
|
18
|
+
const CACHE_DIR = join(CACHE_ROOT, `v${PACKAGE_VERSION}`);
|
|
19
|
+
|
|
13
20
|
// Platform mapping for GitHub releases
|
|
14
21
|
const PLATFORM_MAP = {
|
|
15
22
|
'darwin-x64': 'tsgo-darwin-amd64',
|
|
@@ -60,6 +67,13 @@ function download(url, dest) {
|
|
|
60
67
|
});
|
|
61
68
|
}
|
|
62
69
|
|
|
70
|
+
function finalizeBinary() {
|
|
71
|
+
// Make executable (Unix-like systems)
|
|
72
|
+
if (process.platform !== 'win32') {
|
|
73
|
+
chmodSync(BIN_PATH, 0o755);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
63
77
|
async function install() {
|
|
64
78
|
try {
|
|
65
79
|
// Check if binary already exists (useful for development)
|
|
@@ -68,24 +82,41 @@ async function install() {
|
|
|
68
82
|
return;
|
|
69
83
|
}
|
|
70
84
|
|
|
71
|
-
console.log('Installing vue-go-tsc...');
|
|
72
|
-
|
|
73
|
-
const platformBinary = getPlatformBinary();
|
|
74
|
-
const downloadUrl = `https://github.com/aidalinfo/vue-tsgo/releases/download/v${PACKAGE_VERSION}/${platformBinary}`;
|
|
75
|
-
|
|
76
|
-
console.log(`Downloading from: ${downloadUrl}`);
|
|
77
|
-
|
|
78
|
-
// Ensure bin directory exists
|
|
79
85
|
if (!existsSync(BIN_DIR)) {
|
|
80
86
|
mkdirSync(BIN_DIR, { recursive: true });
|
|
81
87
|
}
|
|
82
88
|
|
|
83
|
-
|
|
89
|
+
const platformBinary = getPlatformBinary();
|
|
90
|
+
const cachedBinary = join(CACHE_DIR, platformBinary);
|
|
91
|
+
|
|
92
|
+
// 1) Serve from the shared cache when present (best-effort — a cache miss or
|
|
93
|
+
// error just falls through to the download below).
|
|
94
|
+
try {
|
|
95
|
+
if (existsSync(cachedBinary)) {
|
|
96
|
+
copyFileSync(cachedBinary, BIN_PATH);
|
|
97
|
+
finalizeBinary();
|
|
98
|
+
console.log(`✓ vue-go-tsc restored from cache (${cachedBinary})`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
} catch {
|
|
102
|
+
// ignore — download is the source of truth
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 2) Download from the GitHub Release for this version.
|
|
106
|
+
const downloadUrl = `https://github.com/aidalinfo/vue-tsgo/releases/download/v${PACKAGE_VERSION}/${platformBinary}`;
|
|
107
|
+
console.log('Installing vue-go-tsc...');
|
|
108
|
+
console.log(`Downloading from: ${downloadUrl}`);
|
|
84
109
|
await download(downloadUrl, BIN_PATH);
|
|
110
|
+
finalizeBinary();
|
|
85
111
|
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
112
|
+
// 3) Populate the cache for next time (never fail the install on this).
|
|
113
|
+
try {
|
|
114
|
+
if (!existsSync(CACHE_DIR)) {
|
|
115
|
+
mkdirSync(CACHE_DIR, { recursive: true });
|
|
116
|
+
}
|
|
117
|
+
copyFileSync(BIN_PATH, cachedBinary);
|
|
118
|
+
} catch {
|
|
119
|
+
// cache is an optimization only
|
|
89
120
|
}
|
|
90
121
|
|
|
91
122
|
console.log('✓ vue-go-tsc installed successfully!');
|