lwc-convert 1.8.2 → 1.9.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/index.js +118 -100
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51,8 +51,8 @@ var init_esm_shims = __esm({
|
|
|
51
51
|
import { readFileSync } from "fs";
|
|
52
52
|
import { join } from "path";
|
|
53
53
|
function getPackageVersion() {
|
|
54
|
-
if ("1.
|
|
55
|
-
return "1.
|
|
54
|
+
if ("1.9.0") {
|
|
55
|
+
return "1.9.0";
|
|
56
56
|
}
|
|
57
57
|
try {
|
|
58
58
|
const possiblePaths = [
|
|
@@ -9265,6 +9265,107 @@ var init_vf = __esm({
|
|
|
9265
9265
|
}
|
|
9266
9266
|
});
|
|
9267
9267
|
|
|
9268
|
+
// src/utils/update-checker.ts
|
|
9269
|
+
import fs7 from "fs-extra";
|
|
9270
|
+
import path10 from "path";
|
|
9271
|
+
import os3 from "os";
|
|
9272
|
+
async function fetchLatestVersion() {
|
|
9273
|
+
try {
|
|
9274
|
+
const controller = new AbortController();
|
|
9275
|
+
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
9276
|
+
const response = await fetch(`https://registry.npmjs.org/${CLI_NAME}/latest`, {
|
|
9277
|
+
signal: controller.signal,
|
|
9278
|
+
headers: { "Accept": "application/json" }
|
|
9279
|
+
});
|
|
9280
|
+
clearTimeout(timeout);
|
|
9281
|
+
if (!response.ok) return null;
|
|
9282
|
+
const data = await response.json();
|
|
9283
|
+
return data.version || null;
|
|
9284
|
+
} catch {
|
|
9285
|
+
return null;
|
|
9286
|
+
}
|
|
9287
|
+
}
|
|
9288
|
+
function parseVersion(version) {
|
|
9289
|
+
const cleaned = version.replace(/^v/, "").replace(/[-+].*$/, "");
|
|
9290
|
+
return cleaned.split(".").map((n) => parseInt(n, 10) || 0);
|
|
9291
|
+
}
|
|
9292
|
+
function isPreRelease(version) {
|
|
9293
|
+
return /[-]/.test(version.replace(/^v/, ""));
|
|
9294
|
+
}
|
|
9295
|
+
function isNewerVersion(latest, current) {
|
|
9296
|
+
if (isPreRelease(latest)) return false;
|
|
9297
|
+
const latestParts = parseVersion(latest);
|
|
9298
|
+
const currentParts = parseVersion(current);
|
|
9299
|
+
for (let i = 0; i < Math.max(latestParts.length, currentParts.length); i++) {
|
|
9300
|
+
const l = latestParts[i] || 0;
|
|
9301
|
+
const c = currentParts[i] || 0;
|
|
9302
|
+
if (l > c) return true;
|
|
9303
|
+
if (l < c) return false;
|
|
9304
|
+
}
|
|
9305
|
+
return false;
|
|
9306
|
+
}
|
|
9307
|
+
async function readCache() {
|
|
9308
|
+
try {
|
|
9309
|
+
if (await fs7.pathExists(CACHE_FILE)) {
|
|
9310
|
+
return await fs7.readJson(CACHE_FILE);
|
|
9311
|
+
}
|
|
9312
|
+
} catch {
|
|
9313
|
+
}
|
|
9314
|
+
return null;
|
|
9315
|
+
}
|
|
9316
|
+
async function writeCache(cache) {
|
|
9317
|
+
try {
|
|
9318
|
+
await fs7.writeJson(CACHE_FILE, cache);
|
|
9319
|
+
} catch {
|
|
9320
|
+
}
|
|
9321
|
+
}
|
|
9322
|
+
async function checkForUpdates() {
|
|
9323
|
+
const currentVersion = CLI_VERSION;
|
|
9324
|
+
const result = { hasUpdate: false, currentVersion, latestVersion: void 0 };
|
|
9325
|
+
try {
|
|
9326
|
+
const cache = await readCache();
|
|
9327
|
+
const now = Date.now();
|
|
9328
|
+
if (cache && now - cache.lastCheck < CHECK_INTERVAL_MS) {
|
|
9329
|
+
if (cache.latestVersion && isNewerVersion(cache.latestVersion, currentVersion)) {
|
|
9330
|
+
result.hasUpdate = true;
|
|
9331
|
+
result.latestVersion = cache.latestVersion;
|
|
9332
|
+
}
|
|
9333
|
+
return result;
|
|
9334
|
+
}
|
|
9335
|
+
const latestVersion = await fetchLatestVersion();
|
|
9336
|
+
await writeCache({ lastCheck: now, latestVersion });
|
|
9337
|
+
if (latestVersion && isNewerVersion(latestVersion, currentVersion)) {
|
|
9338
|
+
result.hasUpdate = true;
|
|
9339
|
+
result.latestVersion = latestVersion;
|
|
9340
|
+
}
|
|
9341
|
+
} catch {
|
|
9342
|
+
}
|
|
9343
|
+
return result;
|
|
9344
|
+
}
|
|
9345
|
+
function formatUpdateMessage(latestVersion, currentVersion) {
|
|
9346
|
+
const versionText = `${currentVersion} \u2192 ${latestVersion}`;
|
|
9347
|
+
const updateCmd = `npm i -g ${CLI_NAME}`;
|
|
9348
|
+
const line1Content = ` Update available: ${versionText} `;
|
|
9349
|
+
const line2Content = ` Run ${updateCmd} to update `;
|
|
9350
|
+
const innerWidth = Math.max(line1Content.length, line2Content.length);
|
|
9351
|
+
const border = "\u2500".repeat(innerWidth);
|
|
9352
|
+
return `\x1B[33m \u256D${border}\u256E
|
|
9353
|
+
\u2502${line1Content.padEnd(innerWidth)}\u2502
|
|
9354
|
+
\u2502 Run \x1B[36m${updateCmd}\x1B[33m to update${" ".repeat(innerWidth - line2Content.length)} \u2502
|
|
9355
|
+
\u2570${border}\u256F\x1B[0m`;
|
|
9356
|
+
}
|
|
9357
|
+
var CACHE_FILE, CHECK_INTERVAL_MS, FETCH_TIMEOUT_MS;
|
|
9358
|
+
var init_update_checker = __esm({
|
|
9359
|
+
"src/utils/update-checker.ts"() {
|
|
9360
|
+
"use strict";
|
|
9361
|
+
init_esm_shims();
|
|
9362
|
+
init_options();
|
|
9363
|
+
CACHE_FILE = path10.join(os3.tmpdir(), "lwc-convert-update-check.json");
|
|
9364
|
+
CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
9365
|
+
FETCH_TIMEOUT_MS = 3e3;
|
|
9366
|
+
}
|
|
9367
|
+
});
|
|
9368
|
+
|
|
9268
9369
|
// src/grading/grade-calculator.ts
|
|
9269
9370
|
var GradeCalculator;
|
|
9270
9371
|
var init_grade_calculator = __esm({
|
|
@@ -15173,20 +15274,31 @@ function startTui() {
|
|
|
15173
15274
|
exitOnCtrlC: false
|
|
15174
15275
|
// We handle quit ourselves with 'q'
|
|
15175
15276
|
});
|
|
15176
|
-
waitUntilExit().then(() => {
|
|
15277
|
+
waitUntilExit().then(async () => {
|
|
15177
15278
|
process.stdout.write("\x1B[?25h");
|
|
15178
15279
|
process.stdout.write("\x1B[?1049l");
|
|
15280
|
+
try {
|
|
15281
|
+
const updateInfo = await updateCheckPromise;
|
|
15282
|
+
if (updateInfo.hasUpdate && updateInfo.latestVersion) {
|
|
15283
|
+
console.log("");
|
|
15284
|
+
console.log(formatUpdateMessage(updateInfo.latestVersion, updateInfo.currentVersion));
|
|
15285
|
+
}
|
|
15286
|
+
} catch {
|
|
15287
|
+
}
|
|
15179
15288
|
process.exit(0);
|
|
15180
15289
|
});
|
|
15181
15290
|
}
|
|
15291
|
+
var updateCheckPromise;
|
|
15182
15292
|
var init_tui = __esm({
|
|
15183
15293
|
"src/tui/index.tsx"() {
|
|
15184
15294
|
"use strict";
|
|
15185
15295
|
init_esm_shims();
|
|
15186
15296
|
init_App();
|
|
15297
|
+
init_update_checker();
|
|
15187
15298
|
init_App();
|
|
15188
15299
|
init_store();
|
|
15189
15300
|
init_types();
|
|
15301
|
+
updateCheckPromise = checkForUpdates();
|
|
15190
15302
|
}
|
|
15191
15303
|
});
|
|
15192
15304
|
|
|
@@ -15197,103 +15309,9 @@ init_aura();
|
|
|
15197
15309
|
init_vf();
|
|
15198
15310
|
init_logger();
|
|
15199
15311
|
init_session_store();
|
|
15312
|
+
init_update_checker();
|
|
15200
15313
|
import { Command } from "commander";
|
|
15201
15314
|
|
|
15202
|
-
// src/utils/update-checker.ts
|
|
15203
|
-
init_esm_shims();
|
|
15204
|
-
init_options();
|
|
15205
|
-
import fs7 from "fs-extra";
|
|
15206
|
-
import path10 from "path";
|
|
15207
|
-
import os3 from "os";
|
|
15208
|
-
var CACHE_FILE = path10.join(os3.tmpdir(), "lwc-convert-update-check.json");
|
|
15209
|
-
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
15210
|
-
var FETCH_TIMEOUT_MS = 3e3;
|
|
15211
|
-
async function fetchLatestVersion() {
|
|
15212
|
-
try {
|
|
15213
|
-
const controller = new AbortController();
|
|
15214
|
-
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
15215
|
-
const response = await fetch(`https://registry.npmjs.org/${CLI_NAME}/latest`, {
|
|
15216
|
-
signal: controller.signal,
|
|
15217
|
-
headers: { "Accept": "application/json" }
|
|
15218
|
-
});
|
|
15219
|
-
clearTimeout(timeout);
|
|
15220
|
-
if (!response.ok) return null;
|
|
15221
|
-
const data = await response.json();
|
|
15222
|
-
return data.version || null;
|
|
15223
|
-
} catch {
|
|
15224
|
-
return null;
|
|
15225
|
-
}
|
|
15226
|
-
}
|
|
15227
|
-
function parseVersion(version) {
|
|
15228
|
-
const cleaned = version.replace(/^v/, "").replace(/[-+].*$/, "");
|
|
15229
|
-
return cleaned.split(".").map((n) => parseInt(n, 10) || 0);
|
|
15230
|
-
}
|
|
15231
|
-
function isPreRelease(version) {
|
|
15232
|
-
return /[-]/.test(version.replace(/^v/, ""));
|
|
15233
|
-
}
|
|
15234
|
-
function isNewerVersion(latest, current) {
|
|
15235
|
-
if (isPreRelease(latest)) return false;
|
|
15236
|
-
const latestParts = parseVersion(latest);
|
|
15237
|
-
const currentParts = parseVersion(current);
|
|
15238
|
-
for (let i = 0; i < Math.max(latestParts.length, currentParts.length); i++) {
|
|
15239
|
-
const l = latestParts[i] || 0;
|
|
15240
|
-
const c = currentParts[i] || 0;
|
|
15241
|
-
if (l > c) return true;
|
|
15242
|
-
if (l < c) return false;
|
|
15243
|
-
}
|
|
15244
|
-
return false;
|
|
15245
|
-
}
|
|
15246
|
-
async function readCache() {
|
|
15247
|
-
try {
|
|
15248
|
-
if (await fs7.pathExists(CACHE_FILE)) {
|
|
15249
|
-
return await fs7.readJson(CACHE_FILE);
|
|
15250
|
-
}
|
|
15251
|
-
} catch {
|
|
15252
|
-
}
|
|
15253
|
-
return null;
|
|
15254
|
-
}
|
|
15255
|
-
async function writeCache(cache) {
|
|
15256
|
-
try {
|
|
15257
|
-
await fs7.writeJson(CACHE_FILE, cache);
|
|
15258
|
-
} catch {
|
|
15259
|
-
}
|
|
15260
|
-
}
|
|
15261
|
-
async function checkForUpdates() {
|
|
15262
|
-
const currentVersion = CLI_VERSION;
|
|
15263
|
-
const result = { hasUpdate: false, currentVersion, latestVersion: void 0 };
|
|
15264
|
-
try {
|
|
15265
|
-
const cache = await readCache();
|
|
15266
|
-
const now = Date.now();
|
|
15267
|
-
if (cache && now - cache.lastCheck < CHECK_INTERVAL_MS) {
|
|
15268
|
-
if (cache.latestVersion && isNewerVersion(cache.latestVersion, currentVersion)) {
|
|
15269
|
-
result.hasUpdate = true;
|
|
15270
|
-
result.latestVersion = cache.latestVersion;
|
|
15271
|
-
}
|
|
15272
|
-
return result;
|
|
15273
|
-
}
|
|
15274
|
-
const latestVersion = await fetchLatestVersion();
|
|
15275
|
-
await writeCache({ lastCheck: now, latestVersion });
|
|
15276
|
-
if (latestVersion && isNewerVersion(latestVersion, currentVersion)) {
|
|
15277
|
-
result.hasUpdate = true;
|
|
15278
|
-
result.latestVersion = latestVersion;
|
|
15279
|
-
}
|
|
15280
|
-
} catch {
|
|
15281
|
-
}
|
|
15282
|
-
return result;
|
|
15283
|
-
}
|
|
15284
|
-
function formatUpdateMessage(latestVersion, currentVersion) {
|
|
15285
|
-
const versionText = `${currentVersion} \u2192 ${latestVersion}`;
|
|
15286
|
-
const updateCmd = `npm i -g ${CLI_NAME}`;
|
|
15287
|
-
const line1Content = ` Update available: ${versionText} `;
|
|
15288
|
-
const line2Content = ` Run ${updateCmd} to update `;
|
|
15289
|
-
const innerWidth = Math.max(line1Content.length, line2Content.length);
|
|
15290
|
-
const border = "\u2500".repeat(innerWidth);
|
|
15291
|
-
return `\x1B[33m \u256D${border}\u256E
|
|
15292
|
-
\u2502${line1Content.padEnd(innerWidth)}\u2502
|
|
15293
|
-
\u2502 Run \x1B[36m${updateCmd}\x1B[33m to update${" ".repeat(innerWidth - line2Content.length)} \u2502
|
|
15294
|
-
\u2570${border}\u256F\x1B[0m`;
|
|
15295
|
-
}
|
|
15296
|
-
|
|
15297
15315
|
// src/cli/commands/grade.ts
|
|
15298
15316
|
init_esm_shims();
|
|
15299
15317
|
init_logger();
|
|
@@ -17734,11 +17752,11 @@ async function writeOutput(filePath, content) {
|
|
|
17734
17752
|
}
|
|
17735
17753
|
|
|
17736
17754
|
// src/index.ts
|
|
17737
|
-
var
|
|
17755
|
+
var updateCheckPromise2 = checkForUpdates();
|
|
17738
17756
|
var program = new Command();
|
|
17739
17757
|
program.name(CLI_NAME).description(CLI_DESCRIPTION).version(CLI_VERSION).hook("postAction", async () => {
|
|
17740
17758
|
try {
|
|
17741
|
-
const updateInfo = await
|
|
17759
|
+
const updateInfo = await updateCheckPromise2;
|
|
17742
17760
|
if (updateInfo.hasUpdate && updateInfo.latestVersion) {
|
|
17743
17761
|
console.log("");
|
|
17744
17762
|
console.log(formatUpdateMessage(updateInfo.latestVersion, updateInfo.currentVersion));
|