@staff0rd/assist 0.50.0 → 0.51.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 +49 -34
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { Command } from "commander";
|
|
|
7
7
|
// package.json
|
|
8
8
|
var package_default = {
|
|
9
9
|
name: "@staff0rd/assist",
|
|
10
|
-
version: "0.
|
|
10
|
+
version: "0.51.0",
|
|
11
11
|
type: "module",
|
|
12
12
|
main: "dist/index.js",
|
|
13
13
|
bin: {
|
|
@@ -802,7 +802,7 @@ function detectExistingSetup(pkg) {
|
|
|
802
802
|
};
|
|
803
803
|
}
|
|
804
804
|
|
|
805
|
-
// src/commands/verify/init/options.ts
|
|
805
|
+
// src/commands/verify/init/getAvailableOptions/options.ts
|
|
806
806
|
function getBuildDescription(setup) {
|
|
807
807
|
if (setup.hasVite && setup.hasTypescript)
|
|
808
808
|
return "TypeScript + Vite build verification";
|
|
@@ -863,7 +863,7 @@ var options = [
|
|
|
863
863
|
}
|
|
864
864
|
];
|
|
865
865
|
|
|
866
|
-
// src/commands/verify/init/getAvailableOptions.ts
|
|
866
|
+
// src/commands/verify/init/getAvailableOptions/index.ts
|
|
867
867
|
function resolveDescription(desc, setup) {
|
|
868
868
|
return typeof desc === "function" ? desc(setup) : desc;
|
|
869
869
|
}
|
|
@@ -962,15 +962,16 @@ function removeVscodeFromGitignore() {
|
|
|
962
962
|
console.log(chalk16.dim("Removed .vscode references from .gitignore"));
|
|
963
963
|
}
|
|
964
964
|
}
|
|
965
|
-
function createLaunchJson() {
|
|
965
|
+
function createLaunchJson(type) {
|
|
966
|
+
const command = type === "vite" ? "npm run dev -- --open" : "npm run start";
|
|
966
967
|
const launchConfig = {
|
|
967
968
|
version: "0.2.0",
|
|
968
969
|
configurations: [
|
|
969
970
|
{
|
|
970
|
-
name:
|
|
971
|
+
name: command,
|
|
971
972
|
type: "node-terminal",
|
|
972
973
|
request: "launch",
|
|
973
|
-
command
|
|
974
|
+
command
|
|
974
975
|
}
|
|
975
976
|
]
|
|
976
977
|
};
|
|
@@ -1014,25 +1015,26 @@ function detectVscodeSetup(pkg) {
|
|
|
1014
1015
|
hasVscodeFolder: fs4.existsSync(vscodeDir),
|
|
1015
1016
|
hasLaunchJson: fs4.existsSync(path10.join(vscodeDir, "launch.json")),
|
|
1016
1017
|
hasSettingsJson: fs4.existsSync(path10.join(vscodeDir, "settings.json")),
|
|
1017
|
-
hasVite: !!pkg.devDependencies?.vite || !!pkg.dependencies?.vite
|
|
1018
|
+
hasVite: !!pkg.devDependencies?.vite || !!pkg.dependencies?.vite,
|
|
1019
|
+
hasTsup: !!pkg.devDependencies?.tsup || !!pkg.dependencies?.tsup
|
|
1018
1020
|
};
|
|
1019
1021
|
}
|
|
1020
1022
|
|
|
1021
|
-
// src/commands/vscode/init/
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
};
|
|
1023
|
+
// src/commands/vscode/init/getAvailableOptions.ts
|
|
1024
|
+
function getLaunchDescription(setup) {
|
|
1025
|
+
if (setup.hasLaunchJson) return void 0;
|
|
1026
|
+
if (setup.hasVite) return "Debug configuration for Vite dev server";
|
|
1027
|
+
if (setup.hasTsup) return "Debug configuration for Node.js CLI";
|
|
1028
|
+
return void 0;
|
|
1029
|
+
}
|
|
1029
1030
|
function getAvailableOptions2(setup) {
|
|
1030
1031
|
const options2 = [];
|
|
1031
|
-
|
|
1032
|
+
const launchDescription = getLaunchDescription(setup);
|
|
1033
|
+
if (launchDescription)
|
|
1032
1034
|
options2.push({
|
|
1033
1035
|
name: "launch",
|
|
1034
1036
|
value: "launch",
|
|
1035
|
-
description:
|
|
1037
|
+
description: launchDescription
|
|
1036
1038
|
});
|
|
1037
1039
|
if (!setup.hasSettingsJson)
|
|
1038
1040
|
options2.push({
|
|
@@ -1042,26 +1044,39 @@ function getAvailableOptions2(setup) {
|
|
|
1042
1044
|
});
|
|
1043
1045
|
return options2;
|
|
1044
1046
|
}
|
|
1047
|
+
|
|
1048
|
+
// src/commands/vscode/init/index.ts
|
|
1049
|
+
function applySelections(selected, setup) {
|
|
1050
|
+
removeVscodeFromGitignore();
|
|
1051
|
+
ensureVscodeFolder();
|
|
1052
|
+
const launchType = setup.hasVite ? "vite" : "tsup";
|
|
1053
|
+
const handlers = {
|
|
1054
|
+
launch: () => createLaunchJson(launchType),
|
|
1055
|
+
settings: () => {
|
|
1056
|
+
createSettingsJson();
|
|
1057
|
+
createExtensionsJson();
|
|
1058
|
+
}
|
|
1059
|
+
};
|
|
1060
|
+
for (const choice of selected) handlers[choice]?.();
|
|
1061
|
+
}
|
|
1062
|
+
async function promptForOptions(options2) {
|
|
1063
|
+
console.log(chalk17.bold("Available VS Code configurations to add:\n"));
|
|
1064
|
+
return promptMultiselect("Select configurations to add:", options2);
|
|
1065
|
+
}
|
|
1045
1066
|
async function init3() {
|
|
1046
1067
|
const { pkg } = requirePackageJson();
|
|
1047
1068
|
const setup = detectVscodeSetup(pkg);
|
|
1048
|
-
const
|
|
1049
|
-
if (
|
|
1069
|
+
const options2 = getAvailableOptions2(setup);
|
|
1070
|
+
if (options2.length === 0) {
|
|
1050
1071
|
console.log(chalk17.green("VS Code configuration already exists!"));
|
|
1051
1072
|
return;
|
|
1052
1073
|
}
|
|
1053
|
-
|
|
1054
|
-
const selected = await promptMultiselect(
|
|
1055
|
-
"Select configurations to add:",
|
|
1056
|
-
availableOptions
|
|
1057
|
-
);
|
|
1074
|
+
const selected = await promptForOptions(options2);
|
|
1058
1075
|
if (selected.length === 0) {
|
|
1059
1076
|
console.log(chalk17.yellow("No configurations selected"));
|
|
1060
1077
|
return;
|
|
1061
1078
|
}
|
|
1062
|
-
|
|
1063
|
-
ensureVscodeFolder();
|
|
1064
|
-
for (const choice of selected) SETUP_HANDLERS[choice]?.();
|
|
1079
|
+
applySelections(selected, setup);
|
|
1065
1080
|
console.log(
|
|
1066
1081
|
chalk17.green(`
|
|
1067
1082
|
Added ${selected.length} VS Code configuration(s)`)
|
|
@@ -1261,7 +1276,7 @@ function lint() {
|
|
|
1261
1276
|
}
|
|
1262
1277
|
}
|
|
1263
1278
|
|
|
1264
|
-
// src/commands/new/newCli.ts
|
|
1279
|
+
// src/commands/new/registerNew/newCli/index.ts
|
|
1265
1280
|
import { execSync as execSync7 } from "child_process";
|
|
1266
1281
|
import { basename as basename2, resolve } from "path";
|
|
1267
1282
|
|
|
@@ -1417,7 +1432,7 @@ async function run(options2 = {}) {
|
|
|
1417
1432
|
await executeVerifyScripts(found, options2.timer ?? false);
|
|
1418
1433
|
}
|
|
1419
1434
|
|
|
1420
|
-
// src/commands/new/initPackageJson.ts
|
|
1435
|
+
// src/commands/new/registerNew/newCli/initPackageJson.ts
|
|
1421
1436
|
import { execSync as execSync6 } from "child_process";
|
|
1422
1437
|
function initPackageJson(name) {
|
|
1423
1438
|
console.log("Initializing package.json...");
|
|
@@ -1432,7 +1447,7 @@ function initPackageJson(name) {
|
|
|
1432
1447
|
});
|
|
1433
1448
|
}
|
|
1434
1449
|
|
|
1435
|
-
// src/commands/new/writeCliTemplate.ts
|
|
1450
|
+
// src/commands/new/registerNew/newCli/writeCliTemplate.ts
|
|
1436
1451
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
1437
1452
|
function writeCliTemplate(name) {
|
|
1438
1453
|
console.log("Writing tsconfig.json...");
|
|
@@ -1486,7 +1501,7 @@ program.parse();
|
|
|
1486
1501
|
);
|
|
1487
1502
|
}
|
|
1488
1503
|
|
|
1489
|
-
// src/commands/new/newCli.ts
|
|
1504
|
+
// src/commands/new/registerNew/newCli/index.ts
|
|
1490
1505
|
async function newCli() {
|
|
1491
1506
|
const name = basename2(resolve("."));
|
|
1492
1507
|
initPackageJson(name);
|
|
@@ -1500,7 +1515,7 @@ async function newCli() {
|
|
|
1500
1515
|
await run();
|
|
1501
1516
|
}
|
|
1502
1517
|
|
|
1503
|
-
// src/commands/new/newProject.ts
|
|
1518
|
+
// src/commands/new/registerNew/newProject.ts
|
|
1504
1519
|
import { execSync as execSync9 } from "child_process";
|
|
1505
1520
|
import { existsSync as existsSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "fs";
|
|
1506
1521
|
|
|
@@ -1615,7 +1630,7 @@ async function init5() {
|
|
|
1615
1630
|
printSetupInstructions();
|
|
1616
1631
|
}
|
|
1617
1632
|
|
|
1618
|
-
// src/commands/new/newProject.ts
|
|
1633
|
+
// src/commands/new/registerNew/newProject.ts
|
|
1619
1634
|
async function newProject() {
|
|
1620
1635
|
console.log("Initializing Vite with react-ts template...");
|
|
1621
1636
|
execSync9("npm create vite@latest . -- --template react-ts", {
|
|
@@ -1647,7 +1662,7 @@ function addViteBaseConfig() {
|
|
|
1647
1662
|
}
|
|
1648
1663
|
}
|
|
1649
1664
|
|
|
1650
|
-
// src/commands/new/registerNew.ts
|
|
1665
|
+
// src/commands/new/registerNew/index.ts
|
|
1651
1666
|
function registerNew(program2) {
|
|
1652
1667
|
const newCommand = program2.command("new").description("Scaffold a new project");
|
|
1653
1668
|
newCommand.command("vite").description("Initialize a new Vite React TypeScript project").action(newProject);
|