qtex 1.1.26 ā 1.1.28
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/index.js +25 -10
- package/package.json +1 -1
- package/src/compiler.js +10 -12
- package/src/updater.js +4 -2
package/index.js
CHANGED
|
@@ -20,7 +20,8 @@ const optionsSchema = {
|
|
|
20
20
|
help: { type: 'boolean', short: 'h' },
|
|
21
21
|
update: { type: 'boolean', short: 'u' },
|
|
22
22
|
version: { type: 'boolean', short: 'v' },
|
|
23
|
-
verify: { type: 'boolean' }
|
|
23
|
+
verify: { type: 'boolean' },
|
|
24
|
+
json: { type: 'boolean' }
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
async function main() {
|
|
@@ -47,6 +48,7 @@ ${colors.bold}OPTIONS:${colors.reset}
|
|
|
47
48
|
-u, --update Update to the latest version
|
|
48
49
|
-v, --version Show version information
|
|
49
50
|
--verify Only verify LaTeX without compiling
|
|
51
|
+
--json Output result in JSON format
|
|
50
52
|
-h, --help Show this help message
|
|
51
53
|
`);
|
|
52
54
|
process.exit(0);
|
|
@@ -58,14 +60,17 @@ ${colors.bold}OPTIONS:${colors.reset}
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
const directory = positionals[0] || '.';
|
|
61
|
-
console.log(`${colors.magenta}${colors.bold}\nš qtex CLI v${packageJson.version} (Vanilla)${colors.reset}\n`);
|
|
62
63
|
|
|
63
|
-
if (values.
|
|
64
|
+
if (!values.json) {
|
|
65
|
+
console.log(`${colors.magenta}${colors.bold}\nš qtex CLI v${packageJson.version} (Vanilla)${colors.reset}\n`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (values.server && !values.json) {
|
|
64
69
|
ui.info(`Using compilation server: ${colors.bold}${values.server}${colors.reset}`);
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
// Check for updates in the background
|
|
68
|
-
autoUpdate(packageJson.version);
|
|
73
|
+
autoUpdate(packageJson.version, values.json);
|
|
69
74
|
|
|
70
75
|
if (values.watch) {
|
|
71
76
|
const server = await startServer(4343);
|
|
@@ -105,15 +110,25 @@ ${colors.bold}OPTIONS:${colors.reset}
|
|
|
105
110
|
} else {
|
|
106
111
|
await compile(directory, values);
|
|
107
112
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
if (!values.verify && !values.json) {
|
|
114
|
+
// Auto-open generated PDF in the system browser
|
|
115
|
+
const outputFileName = values.output || 'output.pdf';
|
|
116
|
+
const outputPath = resolve(process.cwd(), directory, outputFileName);
|
|
117
|
+
const openCmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start ""' : 'xdg-open';
|
|
118
|
+
exec(`${openCmd} "${outputPath}"`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (values.json) {
|
|
122
|
+
console.log(JSON.stringify({ success: true }));
|
|
123
|
+
}
|
|
113
124
|
}
|
|
114
125
|
|
|
115
126
|
} catch (e) {
|
|
116
|
-
|
|
127
|
+
if (args.includes('--json')) {
|
|
128
|
+
console.log(JSON.stringify({ success: false, error: e.message }));
|
|
129
|
+
} else {
|
|
130
|
+
ui.error(e.message);
|
|
131
|
+
}
|
|
117
132
|
process.exit(1);
|
|
118
133
|
}
|
|
119
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qtex",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.28",
|
|
4
4
|
"description": "Ultra-fast cloud LaTeX compiler. Compile .tex documents in milliseconds without installing TeXLive or MikTeX. Zero config, sub-second builds, live watch mode.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
package/src/compiler.js
CHANGED
|
@@ -28,7 +28,8 @@ async function getFiles(dir, baseDir = dir) {
|
|
|
28
28
|
export async function compile(dir, options) {
|
|
29
29
|
const outputFileName = options.output || 'output.pdf';
|
|
30
30
|
const serverUrl = options.server || API_BASE;
|
|
31
|
-
const
|
|
31
|
+
const silent = options.json;
|
|
32
|
+
const spinner = silent ? { start: () => spinner, update: () => { }, succeed: () => { }, fail: () => { }, stop: () => { } } : new Spinner(`${colors.blue}Preparing compilation...`).start();
|
|
32
33
|
|
|
33
34
|
try {
|
|
34
35
|
const absoluteDir = resolve(dir);
|
|
@@ -90,14 +91,11 @@ export async function compile(dir, options) {
|
|
|
90
91
|
|
|
91
92
|
if (validation.valid === false) {
|
|
92
93
|
spinner.stop();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
console.log(` ${colors.red}⢠[Line ${err.line || '?'}] ${err.message}${colors.reset}`);
|
|
96
|
-
});
|
|
97
|
-
return;
|
|
94
|
+
const errorDetails = validation.errors.map(err => `[Line ${err.line || '?'}] ${err.message}`).join('\n');
|
|
95
|
+
throw new Error(`Validation failed:\n${errorDetails}`);
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
if (validation.warnings?.length > 0) {
|
|
98
|
+
if (validation.warnings?.length > 0 && !silent) {
|
|
101
99
|
spinner.stop();
|
|
102
100
|
ui.warn('Validation warnings:');
|
|
103
101
|
validation.warnings.forEach(warn => console.log(` ${colors.yellow}ā” ${warn}${colors.reset}`));
|
|
@@ -133,14 +131,14 @@ export async function compile(dir, options) {
|
|
|
133
131
|
}
|
|
134
132
|
|
|
135
133
|
spinner.succeed(`${colors.green}PDF generated in ${colors.bold}${compileTime}ms${colors.reset}`);
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
if (!silent) {
|
|
135
|
+
console.log(`${colors.dim} ā” Files: ${filesReceived} processed${colors.reset}`);
|
|
136
|
+
console.log(`${colors.dim} š Path: ${outputPath}${colors.reset}`);
|
|
137
|
+
}
|
|
138
138
|
} else {
|
|
139
139
|
const errorMsg = await response.text();
|
|
140
140
|
spinner.fail(`Compilation failed (Status ${response.status})`);
|
|
141
|
-
|
|
142
|
-
console.log(`${colors.red}${errorMsg || 'Error details unavailable.'}${colors.reset}`);
|
|
143
|
-
console.log(`${colors.yellow}-----------------\n${colors.reset}`);
|
|
141
|
+
throw new Error(`Compilation error:\n${errorMsg}`);
|
|
144
142
|
}
|
|
145
143
|
} catch (error) {
|
|
146
144
|
spinner.fail('An unexpected error occurred.');
|
package/src/updater.js
CHANGED
|
@@ -44,7 +44,7 @@ function isNewer(latest, current) {
|
|
|
44
44
|
* Checks for updates in the background and launches a detached
|
|
45
45
|
* background process to update the binary if a new version is found.
|
|
46
46
|
*/
|
|
47
|
-
export async function autoUpdate(currentVersion) {
|
|
47
|
+
export async function autoUpdate(currentVersion, silent = false) {
|
|
48
48
|
const state = await getState();
|
|
49
49
|
const now = Date.now();
|
|
50
50
|
const ONE_DAY = 24 * 60 * 60 * 1000;
|
|
@@ -62,7 +62,9 @@ export async function autoUpdate(currentVersion) {
|
|
|
62
62
|
await saveState({ ...state, lastCheck: now });
|
|
63
63
|
|
|
64
64
|
if (isNewer(latestVersion, currentVersion)) {
|
|
65
|
-
|
|
65
|
+
if (!silent) {
|
|
66
|
+
console.log(`${colors.dim}\nš New version detected (${data.tag_name}). Updating silently in background...${colors.reset}`);
|
|
67
|
+
}
|
|
66
68
|
|
|
67
69
|
// Platform-aware install command
|
|
68
70
|
let installCmd, shell;
|