nexu-app 2.0.1 → 2.0.3
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 +46 -5
- package/package.json +1 -1
- package/templates/default/package.json +1 -0
package/dist/index.js
CHANGED
|
@@ -148,6 +148,22 @@ function getRunCommand(pm) {
|
|
|
148
148
|
return "npm run";
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
+
function getPackageManagerVersion(pm) {
|
|
152
|
+
try {
|
|
153
|
+
const version = execSync(`${pm} --version`, {
|
|
154
|
+
encoding: "utf-8",
|
|
155
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
156
|
+
}).trim();
|
|
157
|
+
return version;
|
|
158
|
+
} catch {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function getPackageManagerField(pm) {
|
|
163
|
+
const version = getPackageManagerVersion(pm);
|
|
164
|
+
if (!version) return null;
|
|
165
|
+
return `${pm}@${version}`;
|
|
166
|
+
}
|
|
151
167
|
function getInstallCommand(pm) {
|
|
152
168
|
switch (pm) {
|
|
153
169
|
case "pnpm":
|
|
@@ -455,7 +471,12 @@ async function init(projectName, options) {
|
|
|
455
471
|
const packageJsonPath = path3.join(projectDir, "package.json");
|
|
456
472
|
const packageJson2 = fs3.readJsonSync(packageJsonPath);
|
|
457
473
|
packageJson2.name = projectName;
|
|
458
|
-
|
|
474
|
+
const pmField = getPackageManagerField(packageManager);
|
|
475
|
+
if (pmField) {
|
|
476
|
+
packageJson2.packageManager = pmField;
|
|
477
|
+
} else {
|
|
478
|
+
delete packageJson2.packageManager;
|
|
479
|
+
}
|
|
459
480
|
if (!features.includes("changesets")) {
|
|
460
481
|
delete packageJson2.scripts["changeset"];
|
|
461
482
|
delete packageJson2.scripts["version-packages"];
|
|
@@ -496,6 +517,13 @@ async function init(projectName, options) {
|
|
|
496
517
|
if (!features.includes("vscode")) {
|
|
497
518
|
fs3.removeSync(path3.join(projectDir, ".vscode"));
|
|
498
519
|
}
|
|
520
|
+
const preCommitPath = path3.join(projectDir, ".husky", "pre-commit");
|
|
521
|
+
if (fs3.existsSync(preCommitPath)) {
|
|
522
|
+
const lintStagedCmd = packageManager === "npm" ? "npx lint-staged" : `${packageManager} lint-staged`;
|
|
523
|
+
fs3.writeFileSync(preCommitPath, `export COREPACK_ENABLE_STRICT=0
|
|
524
|
+
${lintStagedCmd}
|
|
525
|
+
`);
|
|
526
|
+
}
|
|
499
527
|
if (packageManager === "yarn") {
|
|
500
528
|
fs3.removeSync(path3.join(projectDir, "pnpm-workspace.yaml"));
|
|
501
529
|
fs3.removeSync(path3.join(projectDir, ".npmrc"));
|
|
@@ -1107,10 +1135,23 @@ ${change.relativePath}:`));
|
|
|
1107
1135
|
}
|
|
1108
1136
|
const projectPkgFixPath = path4.join(projectDir, "package.json");
|
|
1109
1137
|
const projectPkgFix = fs4.readJsonSync(projectPkgFixPath);
|
|
1110
|
-
if (projectPkgFix.packageManager) {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1138
|
+
if (!projectPkgFix.packageManager) {
|
|
1139
|
+
const pm = detectPackageManager(projectDir);
|
|
1140
|
+
const pmField = getPackageManagerField(pm);
|
|
1141
|
+
if (pmField) {
|
|
1142
|
+
projectPkgFix.packageManager = pmField;
|
|
1143
|
+
fs4.writeJsonSync(projectPkgFixPath, projectPkgFix, { spaces: 2 });
|
|
1144
|
+
log(`Added packageManager field: ${pmField}`, "info");
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
const preCommitPath = path4.join(projectDir, ".husky", "pre-commit");
|
|
1148
|
+
if (fs4.existsSync(preCommitPath)) {
|
|
1149
|
+
const preCommitContent = fs4.readFileSync(preCommitPath, "utf-8");
|
|
1150
|
+
if (!preCommitContent.includes("COREPACK_ENABLE_STRICT")) {
|
|
1151
|
+
fs4.writeFileSync(preCommitPath, `export COREPACK_ENABLE_STRICT=0
|
|
1152
|
+
${preCommitContent}`);
|
|
1153
|
+
log("Fixed husky pre-commit hook (added COREPACK_ENABLE_STRICT=0)", "info");
|
|
1154
|
+
}
|
|
1114
1155
|
}
|
|
1115
1156
|
const summary = [];
|
|
1116
1157
|
if (appliedFiles > 0) summary.push(`${appliedFiles} files updated`);
|
package/package.json
CHANGED