create-template-project 1.2.6 → 1.3.1
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
CHANGED
|
@@ -707,8 +707,8 @@ Restrictions & Behavior:
|
|
|
707
707
|
- Seed Files: Files in 'src/', 'client/src/', etc., and ALL markdown files (*.md) are considered "seed" files and are NEVER overwritten or modified during an update to protect your application logic and documentation.
|
|
708
708
|
- package.json: Dependencies and scripts are merged. Existing versions are preserved unless they are missing.
|
|
709
709
|
- Merging: For non-seed files, the tool attempts to merge template changes. If a conflict occurs, it will be marked with standard git conflict markers.
|
|
710
|
-
|
|
711
|
-
`).option("-t, --template <type>", "Template type (cli, web-vanilla, web-app, web-fullstack)").option("--description <description>", "Project description").option("-k, --keywords <keywords>", "Project keywords (comma separated)").option("-a, --author <author>", "Author name (defaults to 'git config user.name')").option("--github-username <username>", "GitHub username (defaults to 'git config github.user')").option("-p, --package-manager <pm>", "Package manager (npm, pnpm, yarn)", "pnpm").option("--create-github-repository", "Create GitHub repository and push initial commit").option("-d, --directory <path>", "Output directory", ".").option("--build", "Run the CI script (lint, build, test) after updating", false).option("--dev", "Run the dev server after scaffolding", false).option("--open", "Open the browser after scaffolding", false).option("--no-progress", "Do not show progress indicators").action(async (opts) => {
|
|
710
|
+
- Confirmation: The command will show a summary of proposed changes and lets you preview diffs before applying.
|
|
711
|
+
`).option("-t, --template <type>", "Template type (cli, web-vanilla, web-app, web-fullstack)").option("--description <description>", "Project description").option("-k, --keywords <keywords>", "Project keywords (comma separated)").option("-a, --author <author>", "Author name (defaults to 'git config user.name')").option("--github-username <username>", "GitHub username (defaults to 'git config github.user')").option("-p, --package-manager <pm>", "Package manager (npm, pnpm, yarn)", "pnpm").option("--create-github-repository", "Create GitHub repository and push initial commit").option("-d, --directory <path>", "Output directory", ".").option("--build", "Run the CI script (lint, build, test) after updating", false).option("--dev", "Run the dev server after scaffolding", false).option("--open", "Open the browser after scaffolding", false).option("--no-progress", "Do not show progress indicators").action(async (opts) => {
|
|
712
712
|
debug$2("Executing \"update\" command with options: %O", opts);
|
|
713
713
|
const directory = path.resolve(opts.directory);
|
|
714
714
|
const pkgPath = path.join(directory, "package.json");
|
|
@@ -1073,6 +1073,27 @@ var isFileRequired = (relativePath, type) => {
|
|
|
1073
1073
|
].includes(type);
|
|
1074
1074
|
return true;
|
|
1075
1075
|
};
|
|
1076
|
+
var buildSimpleUnifiedDiff = (filePath, before, after) => {
|
|
1077
|
+
const beforeLines = before.split("\n");
|
|
1078
|
+
const afterLines = after.split("\n");
|
|
1079
|
+
const diffLines = [
|
|
1080
|
+
`--- a/${filePath}`,
|
|
1081
|
+
`+++ b/${filePath}`,
|
|
1082
|
+
"@@"
|
|
1083
|
+
];
|
|
1084
|
+
const max = Math.max(beforeLines.length, afterLines.length);
|
|
1085
|
+
for (let i = 0; i < max; i += 1) {
|
|
1086
|
+
const oldLine = i < beforeLines.length ? beforeLines[i] : void 0;
|
|
1087
|
+
const newLine = i < afterLines.length ? afterLines[i] : void 0;
|
|
1088
|
+
if (oldLine === newLine) {
|
|
1089
|
+
diffLines.push(` ${oldLine ?? ""}`);
|
|
1090
|
+
continue;
|
|
1091
|
+
}
|
|
1092
|
+
if (oldLine !== void 0) diffLines.push(`-${oldLine}`);
|
|
1093
|
+
if (newLine !== void 0) diffLines.push(`+${newLine}`);
|
|
1094
|
+
}
|
|
1095
|
+
return diffLines.join("\n");
|
|
1096
|
+
};
|
|
1076
1097
|
var getTemplateArchitectureSection;
|
|
1077
1098
|
var generateGeneratedMd;
|
|
1078
1099
|
var isTemplateType = (value) => value === "cli" || value === "web-vanilla" || value === "web-app" || value === "web-fullstack";
|
|
@@ -1231,6 +1252,7 @@ var generateProject = async (opts) => {
|
|
|
1231
1252
|
}
|
|
1232
1253
|
const actions = [];
|
|
1233
1254
|
const pendingOperations = [];
|
|
1255
|
+
const plannedDiffs = [];
|
|
1234
1256
|
for (const t of templates) {
|
|
1235
1257
|
debug$1("Collecting template files for: %s", t.name);
|
|
1236
1258
|
if (t.templateDir !== void 0) {
|
|
@@ -1272,6 +1294,11 @@ var generateProject = async (opts) => {
|
|
|
1272
1294
|
if (isUpdate && exists) {
|
|
1273
1295
|
const existingContent = await fs.readFile(finalTargetPath, "utf8");
|
|
1274
1296
|
if (existingContent.trim() !== content.trim()) {
|
|
1297
|
+
plannedDiffs.push({
|
|
1298
|
+
path: finalRelativePath,
|
|
1299
|
+
before: existingContent,
|
|
1300
|
+
after: content
|
|
1301
|
+
});
|
|
1275
1302
|
const action = {
|
|
1276
1303
|
type: "MODIFY",
|
|
1277
1304
|
path: finalRelativePath,
|
|
@@ -1298,6 +1325,11 @@ var generateProject = async (opts) => {
|
|
|
1298
1325
|
});
|
|
1299
1326
|
}
|
|
1300
1327
|
} else if (!exists) {
|
|
1328
|
+
plannedDiffs.push({
|
|
1329
|
+
path: finalRelativePath,
|
|
1330
|
+
before: "",
|
|
1331
|
+
after: content
|
|
1332
|
+
});
|
|
1301
1333
|
actions.push({
|
|
1302
1334
|
type: "ADD",
|
|
1303
1335
|
path: finalRelativePath,
|
|
@@ -1341,6 +1373,11 @@ var generateProject = async (opts) => {
|
|
|
1341
1373
|
if (isUpdate && exists) {
|
|
1342
1374
|
const existingContent = await fs.readFile(targetPath, "utf8");
|
|
1343
1375
|
if (existingContent.trim() !== content.trim()) {
|
|
1376
|
+
plannedDiffs.push({
|
|
1377
|
+
path: file.path,
|
|
1378
|
+
before: existingContent,
|
|
1379
|
+
after: content
|
|
1380
|
+
});
|
|
1344
1381
|
const action = {
|
|
1345
1382
|
type: "MODIFY",
|
|
1346
1383
|
path: file.path,
|
|
@@ -1367,6 +1404,11 @@ var generateProject = async (opts) => {
|
|
|
1367
1404
|
});
|
|
1368
1405
|
}
|
|
1369
1406
|
} else if (!exists) {
|
|
1407
|
+
plannedDiffs.push({
|
|
1408
|
+
path: file.path,
|
|
1409
|
+
before: "",
|
|
1410
|
+
after: content
|
|
1411
|
+
});
|
|
1370
1412
|
actions.push({
|
|
1371
1413
|
type: "ADD",
|
|
1372
1414
|
path: file.path,
|
|
@@ -1388,6 +1430,12 @@ var generateProject = async (opts) => {
|
|
|
1388
1430
|
let workspaceChanged = true;
|
|
1389
1431
|
if (workspaceExists) workspaceChanged = (await fs.readFile(workspacePath, "utf8")).trim() !== workspaceYaml.trim();
|
|
1390
1432
|
if (workspaceChanged) {
|
|
1433
|
+
const oldWorkspaceContent = workspaceExists ? await fs.readFile(workspacePath, "utf8") : "";
|
|
1434
|
+
plannedDiffs.push({
|
|
1435
|
+
path: "pnpm-workspace.yaml",
|
|
1436
|
+
before: oldWorkspaceContent,
|
|
1437
|
+
after: workspaceYaml
|
|
1438
|
+
});
|
|
1391
1439
|
actions.push({
|
|
1392
1440
|
type: workspaceExists ? "MODIFY" : "ADD",
|
|
1393
1441
|
path: "pnpm-workspace.yaml",
|
|
@@ -1407,6 +1455,12 @@ var generateProject = async (opts) => {
|
|
|
1407
1455
|
let pkgChanged = true;
|
|
1408
1456
|
if (isUpdate && await pathExists(pkgPath)) pkgChanged = (await fs.readFile(pkgPath, "utf8")).trim() !== newPkgContent.trim();
|
|
1409
1457
|
if (pkgChanged) {
|
|
1458
|
+
const oldPkgContent = isUpdate && await pathExists(pkgPath) ? await fs.readFile(pkgPath, "utf8") : "";
|
|
1459
|
+
plannedDiffs.push({
|
|
1460
|
+
path: "package.json",
|
|
1461
|
+
before: oldPkgContent,
|
|
1462
|
+
after: newPkgContent
|
|
1463
|
+
});
|
|
1410
1464
|
if (isUpdate) actions.push({
|
|
1411
1465
|
type: "MODIFY",
|
|
1412
1466
|
path: "package.json",
|
|
@@ -1427,13 +1481,37 @@ var generateProject = async (opts) => {
|
|
|
1427
1481
|
if (summary) {
|
|
1428
1482
|
const relativeProjectDir = path.relative(process.cwd(), projectDir) || ".";
|
|
1429
1483
|
p.note(summary, `Planned changes in ${relativeProjectDir}:`);
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1484
|
+
let confirmed = false;
|
|
1485
|
+
while (!confirmed) {
|
|
1486
|
+
const action = await p.select({
|
|
1487
|
+
message: "Choose next step:",
|
|
1488
|
+
options: [
|
|
1489
|
+
{
|
|
1490
|
+
label: "Show diff",
|
|
1491
|
+
value: "show-diff"
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
label: "Apply changes",
|
|
1495
|
+
value: "apply"
|
|
1496
|
+
},
|
|
1497
|
+
{
|
|
1498
|
+
label: "Cancel update",
|
|
1499
|
+
value: "cancel"
|
|
1500
|
+
}
|
|
1501
|
+
]
|
|
1502
|
+
});
|
|
1503
|
+
if (p.isCancel(action) || action === "cancel") {
|
|
1504
|
+
p.cancel("Update cancelled.");
|
|
1505
|
+
process.exit(0);
|
|
1506
|
+
}
|
|
1507
|
+
if (action === "show-diff") {
|
|
1508
|
+
for (const entry of plannedDiffs) {
|
|
1509
|
+
const diff = buildSimpleUnifiedDiff(entry.path, entry.before, entry.after);
|
|
1510
|
+
p.note(diff, `Diff preview: ${entry.path}`);
|
|
1511
|
+
}
|
|
1512
|
+
continue;
|
|
1513
|
+
}
|
|
1514
|
+
confirmed = true;
|
|
1437
1515
|
}
|
|
1438
1516
|
} else log.info("No changes detected.");
|
|
1439
1517
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {formatter} from "./oxc.config.ts";
|
|
2
2
|
export default formatter;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {linter} from "./oxc.config.ts";
|
|
2
2
|
export default linter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-template-project",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "An ultra-modular, type-safe Node.js CLI tool used to scaffold new project templates (CLI, Webpage, Webapp, Fullstack) with best-practice configurations pre-installed.",
|
|
6
6
|
"keywords": [
|