nexu-app 2.0.1 → 2.0.2
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 +37 -7
- 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"));
|
|
@@ -1105,12 +1133,14 @@ ${change.relativePath}:`));
|
|
|
1105
1133
|
}
|
|
1106
1134
|
fs4.writeJsonSync(projectPkgPath, projectPkg, { spaces: 2 });
|
|
1107
1135
|
}
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1136
|
+
const preCommitPath = path4.join(projectDir, ".husky", "pre-commit");
|
|
1137
|
+
if (fs4.existsSync(preCommitPath)) {
|
|
1138
|
+
const preCommitContent = fs4.readFileSync(preCommitPath, "utf-8");
|
|
1139
|
+
if (!preCommitContent.includes("COREPACK_ENABLE_STRICT")) {
|
|
1140
|
+
fs4.writeFileSync(preCommitPath, `export COREPACK_ENABLE_STRICT=0
|
|
1141
|
+
${preCommitContent}`);
|
|
1142
|
+
log("Fixed husky pre-commit hook (added COREPACK_ENABLE_STRICT=0)", "info");
|
|
1143
|
+
}
|
|
1114
1144
|
}
|
|
1115
1145
|
const summary = [];
|
|
1116
1146
|
if (appliedFiles > 0) summary.push(`${appliedFiles} files updated`);
|
package/package.json
CHANGED