@qazuor/claude-code-config 0.3.0 → 0.4.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 +4 -1
- package/dist/bin.cjs +183 -59
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +183 -59
- package/dist/bin.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +9 -2
package/dist/bin.js
CHANGED
|
@@ -9,11 +9,11 @@ var __export = (target, all) => {
|
|
|
9
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
// node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js
|
|
12
|
+
// node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js
|
|
13
13
|
import path from "path";
|
|
14
14
|
import { fileURLToPath } from "url";
|
|
15
15
|
var init_esm_shims = __esm({
|
|
16
|
-
"node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js"() {
|
|
16
|
+
"node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js"() {
|
|
17
17
|
"use strict";
|
|
18
18
|
}
|
|
19
19
|
});
|
|
@@ -203,6 +203,7 @@ var init_fs = __esm({
|
|
|
203
203
|
|
|
204
204
|
// src/bin.ts
|
|
205
205
|
init_esm_shims();
|
|
206
|
+
import { createRequire } from "module";
|
|
206
207
|
|
|
207
208
|
// src/cli/index.ts
|
|
208
209
|
init_esm_shims();
|
|
@@ -4800,9 +4801,9 @@ async function readPackageJson(projectPath) {
|
|
|
4800
4801
|
return null;
|
|
4801
4802
|
}
|
|
4802
4803
|
}
|
|
4803
|
-
async function writePackageJson(projectPath,
|
|
4804
|
+
async function writePackageJson(projectPath, packageJson2) {
|
|
4804
4805
|
const packageJsonPath = joinPath(projectPath, "package.json");
|
|
4805
|
-
const content = `${JSON.stringify(
|
|
4806
|
+
const content = `${JSON.stringify(packageJson2, null, 2)}
|
|
4806
4807
|
`;
|
|
4807
4808
|
await writeFile(packageJsonPath, content);
|
|
4808
4809
|
}
|
|
@@ -4882,13 +4883,13 @@ async function updatePackageJson(projectPath, changes, options = {}) {
|
|
|
4882
4883
|
skippedDevDependencies: []
|
|
4883
4884
|
};
|
|
4884
4885
|
try {
|
|
4885
|
-
let
|
|
4886
|
-
if (!
|
|
4886
|
+
let packageJson2 = await readPackageJson(projectPath);
|
|
4887
|
+
if (!packageJson2) {
|
|
4887
4888
|
if (!createIfMissing) {
|
|
4888
4889
|
result.error = "package.json not found and createIfMissing is false";
|
|
4889
4890
|
return result;
|
|
4890
4891
|
}
|
|
4891
|
-
|
|
4892
|
+
packageJson2 = createMinimalPackageJson({
|
|
4892
4893
|
name: changes.metadata?.name,
|
|
4893
4894
|
description: changes.metadata?.description,
|
|
4894
4895
|
author: typeof changes.metadata?.author === "string" ? changes.metadata.author : void 0,
|
|
@@ -4898,46 +4899,46 @@ async function updatePackageJson(projectPath, changes, options = {}) {
|
|
|
4898
4899
|
}
|
|
4899
4900
|
if (backup2 && !dryRun && !result.created) {
|
|
4900
4901
|
const backupPath = joinPath(projectPath, "package.json.backup");
|
|
4901
|
-
await writeFile(backupPath, JSON.stringify(
|
|
4902
|
+
await writeFile(backupPath, JSON.stringify(packageJson2, null, 2));
|
|
4902
4903
|
}
|
|
4903
4904
|
if (changes.metadata) {
|
|
4904
|
-
if (changes.metadata.name && !
|
|
4905
|
-
|
|
4905
|
+
if (changes.metadata.name && !packageJson2.name) {
|
|
4906
|
+
packageJson2.name = changes.metadata.name;
|
|
4906
4907
|
result.modified = true;
|
|
4907
4908
|
}
|
|
4908
|
-
if (changes.metadata.description && !
|
|
4909
|
-
|
|
4909
|
+
if (changes.metadata.description && !packageJson2.description) {
|
|
4910
|
+
packageJson2.description = changes.metadata.description;
|
|
4910
4911
|
result.modified = true;
|
|
4911
4912
|
}
|
|
4912
|
-
if (changes.metadata.author && !
|
|
4913
|
-
|
|
4913
|
+
if (changes.metadata.author && !packageJson2.author) {
|
|
4914
|
+
packageJson2.author = changes.metadata.author;
|
|
4914
4915
|
result.modified = true;
|
|
4915
4916
|
}
|
|
4916
|
-
if (changes.metadata.license && !
|
|
4917
|
-
|
|
4917
|
+
if (changes.metadata.license && !packageJson2.license) {
|
|
4918
|
+
packageJson2.license = changes.metadata.license;
|
|
4918
4919
|
result.modified = true;
|
|
4919
4920
|
}
|
|
4920
|
-
if (changes.metadata.repository && !
|
|
4921
|
-
|
|
4921
|
+
if (changes.metadata.repository && !packageJson2.repository) {
|
|
4922
|
+
packageJson2.repository = changes.metadata.repository;
|
|
4922
4923
|
result.modified = true;
|
|
4923
4924
|
}
|
|
4924
|
-
if (changes.metadata.type && !
|
|
4925
|
-
|
|
4925
|
+
if (changes.metadata.type && !packageJson2.type) {
|
|
4926
|
+
packageJson2.type = changes.metadata.type;
|
|
4926
4927
|
result.modified = true;
|
|
4927
4928
|
}
|
|
4928
|
-
if (changes.metadata.engines && !
|
|
4929
|
-
|
|
4929
|
+
if (changes.metadata.engines && !packageJson2.engines) {
|
|
4930
|
+
packageJson2.engines = changes.metadata.engines;
|
|
4930
4931
|
result.modified = true;
|
|
4931
4932
|
}
|
|
4932
|
-
if (changes.metadata.packageManager && !
|
|
4933
|
-
|
|
4933
|
+
if (changes.metadata.packageManager && !packageJson2.packageManager) {
|
|
4934
|
+
packageJson2.packageManager = changes.metadata.packageManager;
|
|
4934
4935
|
result.modified = true;
|
|
4935
4936
|
}
|
|
4936
4937
|
}
|
|
4937
4938
|
if (changes.scripts) {
|
|
4938
|
-
|
|
4939
|
+
packageJson2.scripts = packageJson2.scripts || {};
|
|
4939
4940
|
for (const [name, command] of Object.entries(changes.scripts)) {
|
|
4940
|
-
const exists = name in
|
|
4941
|
+
const exists = name in packageJson2.scripts;
|
|
4941
4942
|
if (exists) {
|
|
4942
4943
|
if (scriptsMerge === "skip-existing") {
|
|
4943
4944
|
result.skippedScripts.push(name);
|
|
@@ -4948,15 +4949,15 @@ async function updatePackageJson(projectPath, changes, options = {}) {
|
|
|
4948
4949
|
continue;
|
|
4949
4950
|
}
|
|
4950
4951
|
}
|
|
4951
|
-
|
|
4952
|
+
packageJson2.scripts[name] = command;
|
|
4952
4953
|
result.addedScripts.push(name);
|
|
4953
4954
|
result.modified = true;
|
|
4954
4955
|
}
|
|
4955
4956
|
}
|
|
4956
4957
|
if (changes.dependencies) {
|
|
4957
|
-
|
|
4958
|
+
packageJson2.dependencies = packageJson2.dependencies || {};
|
|
4958
4959
|
for (const [name, version] of Object.entries(changes.dependencies)) {
|
|
4959
|
-
const exists = name in
|
|
4960
|
+
const exists = name in packageJson2.dependencies;
|
|
4960
4961
|
if (exists) {
|
|
4961
4962
|
if (dependenciesMerge === "skip-existing") {
|
|
4962
4963
|
result.skippedDependencies.push(name);
|
|
@@ -4967,15 +4968,15 @@ async function updatePackageJson(projectPath, changes, options = {}) {
|
|
|
4967
4968
|
continue;
|
|
4968
4969
|
}
|
|
4969
4970
|
}
|
|
4970
|
-
|
|
4971
|
+
packageJson2.dependencies[name] = version;
|
|
4971
4972
|
result.addedDependencies.push(name);
|
|
4972
4973
|
result.modified = true;
|
|
4973
4974
|
}
|
|
4974
4975
|
}
|
|
4975
4976
|
if (changes.devDependencies) {
|
|
4976
|
-
|
|
4977
|
+
packageJson2.devDependencies = packageJson2.devDependencies || {};
|
|
4977
4978
|
for (const [name, version] of Object.entries(changes.devDependencies)) {
|
|
4978
|
-
const exists = name in
|
|
4979
|
+
const exists = name in packageJson2.devDependencies;
|
|
4979
4980
|
if (exists) {
|
|
4980
4981
|
if (dependenciesMerge === "skip-existing") {
|
|
4981
4982
|
result.skippedDevDependencies.push(name);
|
|
@@ -4986,13 +4987,13 @@ async function updatePackageJson(projectPath, changes, options = {}) {
|
|
|
4986
4987
|
continue;
|
|
4987
4988
|
}
|
|
4988
4989
|
}
|
|
4989
|
-
|
|
4990
|
+
packageJson2.devDependencies[name] = version;
|
|
4990
4991
|
result.addedDevDependencies.push(name);
|
|
4991
4992
|
result.modified = true;
|
|
4992
4993
|
}
|
|
4993
4994
|
}
|
|
4994
4995
|
if (!dryRun && (result.created || result.modified)) {
|
|
4995
|
-
await writePackageJson(projectPath,
|
|
4996
|
+
await writePackageJson(projectPath, packageJson2);
|
|
4996
4997
|
}
|
|
4997
4998
|
result.success = true;
|
|
4998
4999
|
return result;
|
|
@@ -5936,7 +5937,7 @@ async function detectProject(projectPath) {
|
|
|
5936
5937
|
};
|
|
5937
5938
|
}
|
|
5938
5939
|
signals.push({ file: "package.json", exists: true, indicates: "Node.js project" });
|
|
5939
|
-
const
|
|
5940
|
+
const packageJson2 = await readJson(packageJsonPath).catch(() => ({}));
|
|
5940
5941
|
const packageManager = await detectPackageManager(projectPath);
|
|
5941
5942
|
if (packageManager) {
|
|
5942
5943
|
signals.push({
|
|
@@ -5945,11 +5946,11 @@ async function detectProject(projectPath) {
|
|
|
5945
5946
|
indicates: `${packageManager} package manager`
|
|
5946
5947
|
});
|
|
5947
5948
|
}
|
|
5948
|
-
const typeResult = await detectProjectType(projectPath,
|
|
5949
|
+
const typeResult = await detectProjectType(projectPath, packageJson2);
|
|
5949
5950
|
const projectType = typeResult.type;
|
|
5950
5951
|
signals.push(...typeResult.signals);
|
|
5951
5952
|
const confidence = projectType && packageManager ? "high" : projectType || packageManager ? "medium" : "low";
|
|
5952
|
-
const suggestedBundles = suggestBundles(projectType,
|
|
5953
|
+
const suggestedBundles = suggestBundles(projectType, packageJson2);
|
|
5953
5954
|
return {
|
|
5954
5955
|
detected: true,
|
|
5955
5956
|
projectType,
|
|
@@ -5973,10 +5974,10 @@ async function detectPackageManager(projectPath) {
|
|
|
5973
5974
|
}
|
|
5974
5975
|
return void 0;
|
|
5975
5976
|
}
|
|
5976
|
-
async function detectProjectType(projectPath,
|
|
5977
|
+
async function detectProjectType(projectPath, packageJson2) {
|
|
5977
5978
|
const signals = [];
|
|
5978
|
-
const deps = { ...
|
|
5979
|
-
if (await pathExists(joinPath(projectPath, "turbo.json")) || await pathExists(joinPath(projectPath, "pnpm-workspace.yaml")) ||
|
|
5979
|
+
const deps = { ...packageJson2.dependencies, ...packageJson2.devDependencies };
|
|
5980
|
+
if (await pathExists(joinPath(projectPath, "turbo.json")) || await pathExists(joinPath(projectPath, "pnpm-workspace.yaml")) || packageJson2.workspaces) {
|
|
5980
5981
|
signals.push({ file: "turbo.json/pnpm-workspace.yaml", exists: true, indicates: "monorepo" });
|
|
5981
5982
|
return { type: "monorepo", signals };
|
|
5982
5983
|
}
|
|
@@ -6003,8 +6004,8 @@ async function detectProjectType(projectPath, packageJson) {
|
|
|
6003
6004
|
}
|
|
6004
6005
|
return { type: "node", signals };
|
|
6005
6006
|
}
|
|
6006
|
-
function suggestBundles(projectType,
|
|
6007
|
-
const deps = { ...
|
|
6007
|
+
function suggestBundles(projectType, packageJson2) {
|
|
6008
|
+
const deps = { ...packageJson2.dependencies, ...packageJson2.devDependencies };
|
|
6008
6009
|
const suggestedBundles = [];
|
|
6009
6010
|
const hasHono = deps.hono || deps["@hono/node-server"];
|
|
6010
6011
|
const hasExpress = deps.express;
|
|
@@ -6087,8 +6088,8 @@ function suggestBundles(projectType, packageJson) {
|
|
|
6087
6088
|
}
|
|
6088
6089
|
async function getProjectName(projectPath) {
|
|
6089
6090
|
try {
|
|
6090
|
-
const
|
|
6091
|
-
return
|
|
6091
|
+
const packageJson2 = await readJson(joinPath(projectPath, "package.json"));
|
|
6092
|
+
return packageJson2.name;
|
|
6092
6093
|
} catch {
|
|
6093
6094
|
const parts = projectPath.split("/");
|
|
6094
6095
|
return parts[parts.length - 1];
|
|
@@ -6096,8 +6097,8 @@ async function getProjectName(projectPath) {
|
|
|
6096
6097
|
}
|
|
6097
6098
|
async function getProjectDescription(projectPath) {
|
|
6098
6099
|
try {
|
|
6099
|
-
const
|
|
6100
|
-
return
|
|
6100
|
+
const packageJson2 = await readJson(joinPath(projectPath, "package.json"));
|
|
6101
|
+
return packageJson2.description;
|
|
6101
6102
|
} catch {
|
|
6102
6103
|
return void 0;
|
|
6103
6104
|
}
|
|
@@ -9677,6 +9678,10 @@ async function promptMcpConfig(options) {
|
|
|
9677
9678
|
skippedConfigs: []
|
|
9678
9679
|
};
|
|
9679
9680
|
}
|
|
9681
|
+
const projectPath = options?.projectPath || process.cwd();
|
|
9682
|
+
const installedServers = await getInstalledMcpServers(projectPath);
|
|
9683
|
+
const userInstalledSet = new Set(installedServers.user);
|
|
9684
|
+
const projectInstalledSet = new Set(installedServers.project);
|
|
9680
9685
|
const level = await select({
|
|
9681
9686
|
message: "Where should MCP servers be configured?",
|
|
9682
9687
|
choices: [
|
|
@@ -9697,13 +9702,44 @@ async function promptMcpConfig(options) {
|
|
|
9697
9702
|
const selectedServerIds = [];
|
|
9698
9703
|
logger.newline();
|
|
9699
9704
|
logger.info("Select MCP servers to install:");
|
|
9705
|
+
const totalInstalled = userInstalledSet.size + projectInstalledSet.size;
|
|
9706
|
+
if (totalInstalled > 0) {
|
|
9707
|
+
const parts = [];
|
|
9708
|
+
if (userInstalledSet.size > 0) {
|
|
9709
|
+
parts.push(`${userInstalledSet.size} at user level`);
|
|
9710
|
+
}
|
|
9711
|
+
if (projectInstalledSet.size > 0) {
|
|
9712
|
+
parts.push(`${projectInstalledSet.size} at project level`);
|
|
9713
|
+
}
|
|
9714
|
+
logger.info(colors.muted(` (${parts.join(", ")} already installed)`));
|
|
9715
|
+
}
|
|
9700
9716
|
logger.newline();
|
|
9701
9717
|
for (const [category, servers] of Object.entries(serversByCategory)) {
|
|
9702
|
-
const choices = servers.map((s) =>
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9718
|
+
const choices = servers.map((s) => {
|
|
9719
|
+
const isInstalledAtUserLevel = userInstalledSet.has(s.id);
|
|
9720
|
+
const isInstalledAtProjectLevel = projectInstalledSet.has(s.id);
|
|
9721
|
+
if (isInstalledAtUserLevel) {
|
|
9722
|
+
return {
|
|
9723
|
+
name: `${s.name} - ${s.description} ${colors.muted("(already installed at user level)")}`,
|
|
9724
|
+
value: s.id,
|
|
9725
|
+
checked: false,
|
|
9726
|
+
disabled: "already installed at user level"
|
|
9727
|
+
};
|
|
9728
|
+
}
|
|
9729
|
+
if (isInstalledAtProjectLevel) {
|
|
9730
|
+
return {
|
|
9731
|
+
name: `${s.name} - ${s.description} ${colors.muted("(already installed at project level)")}`,
|
|
9732
|
+
value: s.id,
|
|
9733
|
+
checked: false,
|
|
9734
|
+
disabled: "already installed at project level"
|
|
9735
|
+
};
|
|
9736
|
+
}
|
|
9737
|
+
return {
|
|
9738
|
+
name: `${s.name} - ${s.description}`,
|
|
9739
|
+
value: s.id,
|
|
9740
|
+
checked: options?.defaults?.servers?.some((i) => i.serverId === s.id) ?? false
|
|
9741
|
+
};
|
|
9742
|
+
});
|
|
9707
9743
|
const categoryLabel = formatCategory(category);
|
|
9708
9744
|
const selected = await checkbox({
|
|
9709
9745
|
message: `${categoryLabel}:`,
|
|
@@ -10110,7 +10146,7 @@ async function promptBashPermissions(defaults) {
|
|
|
10110
10146
|
async function promptWebPermissions(defaults) {
|
|
10111
10147
|
logger.newline();
|
|
10112
10148
|
logger.info(colors.bold("\u{1F310} Web Operations"));
|
|
10113
|
-
const
|
|
10149
|
+
const fetch2 = await confirm({
|
|
10114
10150
|
message: "Allow WebFetch (fetch web pages)?",
|
|
10115
10151
|
default: defaults?.fetch ?? true
|
|
10116
10152
|
});
|
|
@@ -10119,7 +10155,7 @@ async function promptWebPermissions(defaults) {
|
|
|
10119
10155
|
default: defaults?.search ?? true
|
|
10120
10156
|
});
|
|
10121
10157
|
return {
|
|
10122
|
-
fetch,
|
|
10158
|
+
fetch: fetch2,
|
|
10123
10159
|
search
|
|
10124
10160
|
};
|
|
10125
10161
|
}
|
|
@@ -11201,7 +11237,7 @@ function createMcpConfigStep() {
|
|
|
11201
11237
|
required: false
|
|
11202
11238
|
},
|
|
11203
11239
|
computeDefaults: (ctx) => ctx.mcpConfig,
|
|
11204
|
-
execute: async (
|
|
11240
|
+
execute: async (ctx, defaults) => {
|
|
11205
11241
|
const goBack = await promptBackOption(5, "Configure MCP servers or go back?");
|
|
11206
11242
|
if (goBack) {
|
|
11207
11243
|
return createResult(
|
|
@@ -11209,7 +11245,7 @@ function createMcpConfigStep() {
|
|
|
11209
11245
|
"back"
|
|
11210
11246
|
);
|
|
11211
11247
|
}
|
|
11212
|
-
const result = await promptMcpConfig();
|
|
11248
|
+
const result = await promptMcpConfig({ projectPath: ctx.projectPath });
|
|
11213
11249
|
return createResult(result, "next");
|
|
11214
11250
|
}
|
|
11215
11251
|
};
|
|
@@ -12918,7 +12954,8 @@ async function handleConfigUpdates(projectPath, config, _options) {
|
|
|
12918
12954
|
}
|
|
12919
12955
|
if (reconfigureOptions.includes("mcp")) {
|
|
12920
12956
|
const mcpResult = await promptMcpConfig({
|
|
12921
|
-
defaults: config.mcp
|
|
12957
|
+
defaults: config.mcp,
|
|
12958
|
+
projectPath
|
|
12922
12959
|
});
|
|
12923
12960
|
config.mcp = mcpResult.config;
|
|
12924
12961
|
await installMcpServers(projectPath, mcpResult.config);
|
|
@@ -13259,7 +13296,7 @@ program.addCommand(createConfigureCommand());
|
|
|
13259
13296
|
init_esm_shims();
|
|
13260
13297
|
import chalk3 from "chalk";
|
|
13261
13298
|
import figlet from "figlet";
|
|
13262
|
-
function showBanner() {
|
|
13299
|
+
function showBanner(version) {
|
|
13263
13300
|
const bannerText = figlet.textSync("Qazuor", {
|
|
13264
13301
|
font: "Standard",
|
|
13265
13302
|
horizontalLayout: "default",
|
|
@@ -13285,18 +13322,105 @@ function showBanner() {
|
|
|
13285
13322
|
return colors2[colorIndex](line);
|
|
13286
13323
|
}).join("\n");
|
|
13287
13324
|
console.log(coloredBanner);
|
|
13288
|
-
|
|
13325
|
+
const versionText = version ? chalk3.cyan(` v${version}`) : "";
|
|
13326
|
+
console.log(chalk3.gray(" Claude Code Configuration & Project Setup") + versionText);
|
|
13289
13327
|
console.log(chalk3.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
13290
13328
|
console.log();
|
|
13291
13329
|
}
|
|
13292
13330
|
|
|
13331
|
+
// src/lib/utils/version-check.ts
|
|
13332
|
+
init_esm_shims();
|
|
13333
|
+
import chalk4 from "chalk";
|
|
13334
|
+
var PACKAGE_NAME = "@qazuor/claude-code-config";
|
|
13335
|
+
var NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
13336
|
+
var CHECK_TIMEOUT_MS = 3e3;
|
|
13337
|
+
function compareVersions(a, b) {
|
|
13338
|
+
const partsA = a.replace(/^v/, "").split(".").map(Number);
|
|
13339
|
+
const partsB = b.replace(/^v/, "").split(".").map(Number);
|
|
13340
|
+
for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
|
|
13341
|
+
const numA = partsA[i] || 0;
|
|
13342
|
+
const numB = partsB[i] || 0;
|
|
13343
|
+
if (numA > numB) return 1;
|
|
13344
|
+
if (numA < numB) return -1;
|
|
13345
|
+
}
|
|
13346
|
+
return 0;
|
|
13347
|
+
}
|
|
13348
|
+
async function fetchLatestVersion() {
|
|
13349
|
+
try {
|
|
13350
|
+
const controller = new AbortController();
|
|
13351
|
+
const timeoutId = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS);
|
|
13352
|
+
const response = await fetch(NPM_REGISTRY_URL, {
|
|
13353
|
+
signal: controller.signal,
|
|
13354
|
+
headers: {
|
|
13355
|
+
Accept: "application/json"
|
|
13356
|
+
}
|
|
13357
|
+
});
|
|
13358
|
+
clearTimeout(timeoutId);
|
|
13359
|
+
if (!response.ok) {
|
|
13360
|
+
return null;
|
|
13361
|
+
}
|
|
13362
|
+
const data = await response.json();
|
|
13363
|
+
return data.version || null;
|
|
13364
|
+
} catch {
|
|
13365
|
+
return null;
|
|
13366
|
+
}
|
|
13367
|
+
}
|
|
13368
|
+
async function checkForUpdates(currentVersion) {
|
|
13369
|
+
try {
|
|
13370
|
+
const latestVersion = await fetchLatestVersion();
|
|
13371
|
+
if (!latestVersion) {
|
|
13372
|
+
return;
|
|
13373
|
+
}
|
|
13374
|
+
if (compareVersions(latestVersion, currentVersion) > 0) {
|
|
13375
|
+
displayUpdateNotification(currentVersion, latestVersion);
|
|
13376
|
+
}
|
|
13377
|
+
} catch {
|
|
13378
|
+
}
|
|
13379
|
+
}
|
|
13380
|
+
function displayUpdateNotification(currentVersion, latestVersion) {
|
|
13381
|
+
const boxWidth = 50;
|
|
13382
|
+
const border = chalk4.yellow("\u2502");
|
|
13383
|
+
const topBorder = chalk4.yellow(`\u256D${"\u2500".repeat(boxWidth)}\u256E`);
|
|
13384
|
+
const bottomBorder = chalk4.yellow(`\u2570${"\u2500".repeat(boxWidth)}\u256F`);
|
|
13385
|
+
const padLine = (text, rawLength) => {
|
|
13386
|
+
const padding = boxWidth - rawLength;
|
|
13387
|
+
const leftPad = Math.floor(padding / 2);
|
|
13388
|
+
const rightPad = padding - leftPad;
|
|
13389
|
+
return border + " ".repeat(leftPad) + text + " ".repeat(rightPad) + border;
|
|
13390
|
+
};
|
|
13391
|
+
const emptyLine = border + " ".repeat(boxWidth) + border;
|
|
13392
|
+
const updateText = "Update available!";
|
|
13393
|
+
const versionText = `${chalk4.gray(currentVersion)} \u2192 ${chalk4.green(latestVersion)}`;
|
|
13394
|
+
const versionRawLength = currentVersion.length + " \u2192 ".length + latestVersion.length;
|
|
13395
|
+
const commandText = `npm i -g ${PACKAGE_NAME}`;
|
|
13396
|
+
const runText = `Run: ${chalk4.cyan(commandText)}`;
|
|
13397
|
+
const runRawLength = "Run: ".length + commandText.length;
|
|
13398
|
+
console.log();
|
|
13399
|
+
console.log(topBorder);
|
|
13400
|
+
console.log(emptyLine);
|
|
13401
|
+
console.log(padLine(chalk4.yellow.bold(updateText), updateText.length));
|
|
13402
|
+
console.log(padLine(versionText, versionRawLength));
|
|
13403
|
+
console.log(emptyLine);
|
|
13404
|
+
console.log(padLine(runText, runRawLength));
|
|
13405
|
+
console.log(emptyLine);
|
|
13406
|
+
console.log(bottomBorder);
|
|
13407
|
+
console.log();
|
|
13408
|
+
}
|
|
13409
|
+
function startBackgroundVersionCheck(currentVersion) {
|
|
13410
|
+
return checkForUpdates(currentVersion);
|
|
13411
|
+
}
|
|
13412
|
+
|
|
13293
13413
|
// src/bin.ts
|
|
13414
|
+
var require2 = createRequire(import.meta.url);
|
|
13415
|
+
var packageJson = require2("../package.json");
|
|
13416
|
+
var VERSION3 = packageJson.version;
|
|
13294
13417
|
setupGracefulCancellation();
|
|
13295
13418
|
var args = process.argv.slice(2);
|
|
13296
13419
|
var showBannerCommands = ["init", "help", "--help", "-h", ""];
|
|
13297
13420
|
var shouldShowBanner = args.length === 0 || showBannerCommands.includes(args[0] || "");
|
|
13298
13421
|
if (shouldShowBanner) {
|
|
13299
|
-
showBanner();
|
|
13422
|
+
showBanner(VERSION3);
|
|
13423
|
+
void startBackgroundVersionCheck(VERSION3);
|
|
13300
13424
|
}
|
|
13301
13425
|
program.parse(process.argv);
|
|
13302
13426
|
//# sourceMappingURL=bin.js.map
|