@windrun-huaiin/dev-scripts 6.6.1 → 6.7.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/cli.js CHANGED
@@ -1206,7 +1206,36 @@ async function createDiaomaoApp(targetDir) {
1206
1206
  console.error("Usage: create-diaomao-app <project-name>");
1207
1207
  process.exit(1);
1208
1208
  }
1209
- const destDir = path2__default.default.resolve(process.cwd(), targetDir);
1209
+ const cwd2 = process.cwd();
1210
+ const cwdPackageJson = path2__default.default.join(cwd2, "package.json");
1211
+ const cwdWorkspaceYaml = path2__default.default.join(cwd2, "pnpm-workspace.yaml");
1212
+ const hasPkgJson = await fsExtra.pathExists(cwdPackageJson);
1213
+ const hasWorkspace = await fsExtra.pathExists(cwdWorkspaceYaml);
1214
+ let destDir;
1215
+ let isMonorepo = false;
1216
+ let skipInstallAndGit = false;
1217
+ if (hasPkgJson && hasWorkspace) {
1218
+ console.log("Detected monorepo environment, creating project under apps/");
1219
+ destDir = path2__default.default.resolve(cwd2, "apps", targetDir);
1220
+ isMonorepo = true;
1221
+ skipInstallAndGit = true;
1222
+ if (await fsExtra.pathExists(destDir)) {
1223
+ console.error(`Error: Project 'apps/${targetDir}' already exists in this monorepo!`);
1224
+ console.error(`Please choose a different name or remove the existing project first.`);
1225
+ process.exit(1);
1226
+ }
1227
+ } else if (hasPkgJson && !hasWorkspace) {
1228
+ console.error("Warning: You are in a directory that already contains package.json");
1229
+ console.error("This might create a nested project structure which is usually not intended.");
1230
+ console.error("");
1231
+ console.error("Recommendations:");
1232
+ console.error("- If you want to create a standalone project, run this command in an empty directory");
1233
+ console.error("- If you want to add to a monorepo, run this command in the monorepo root");
1234
+ console.error("");
1235
+ process.exit(1);
1236
+ } else {
1237
+ destDir = path2__default.default.resolve(cwd2, targetDir);
1238
+ }
1210
1239
  const tempDir = path2__default.default.join(os__default.default.tmpdir(), `diaomao-template-${Date.now()}`);
1211
1240
  console.log(`Creating project: ${targetDir}...`);
1212
1241
  try {
@@ -1224,77 +1253,106 @@ async function createDiaomaoApp(targetDir) {
1224
1253
  await fsExtra.rename(envTxtPath, envPath);
1225
1254
  console.log("Renamed .env.local.txt to .env.local");
1226
1255
  }
1256
+ if (isMonorepo) {
1257
+ const changesetDir = path2__default.default.join(destDir, ".changeset");
1258
+ if (await fsExtra.pathExists(changesetDir)) {
1259
+ await fsExtra.remove(changesetDir);
1260
+ console.log("Removed .changeset folder (managed by monorepo root)");
1261
+ }
1262
+ }
1227
1263
  const pkgPath = path2__default.default.join(destDir, "package.json");
1228
1264
  const pkg = await fsExtra.readJson(pkgPath);
1229
1265
  pkg.name = path2__default.default.basename(targetDir);
1230
1266
  pkg.version = "1.0.0";
1231
1267
  pkg.private = true;
1232
- pkg.pnpm = {
1233
- "onlyBuiltDependencies": [
1234
- "@clerk/shared",
1235
- "@parcel/watcher",
1236
- "@tailwindcss/oxide",
1237
- "core-js",
1238
- "esbuild",
1239
- "sharp",
1240
- "unrs-resolver"
1241
- ],
1242
- "overrides": {
1243
- "@types/react": "19.1.2",
1244
- "@types/react-dom": "19.1.3"
1245
- },
1246
- "patchedDependencies": {
1247
- "fumadocs-ui@15.3.3": "patches/fumadocs-ui@15.3.3.patch"
1268
+ if (isMonorepo) {
1269
+ if (pkg.dependencies) {
1270
+ Object.keys(pkg.dependencies).forEach((key) => {
1271
+ if (key.startsWith("@windrun-huaiin/")) {
1272
+ pkg.dependencies[key] = "workspace:^";
1273
+ }
1274
+ });
1248
1275
  }
1249
- };
1250
- pkg.scripts = {
1251
- "postinstall": "fumadocs-mdx",
1252
- "predev": "pnpm run lint",
1253
- "dev": "next dev --turbopack",
1254
- "build": "pnpm generate-blog-index && next build",
1255
- "build:dev": "pnpm generate-blog-index && next build",
1256
- "build:prod": "next build",
1257
- "start": "next start",
1258
- "lint": "next lint",
1259
- "deep-clean": "dev-scripts deep-clean",
1260
- "d8": "pnpm run deep-clean",
1261
- "easy-changeset": "dev-scripts easy-changeset",
1262
- "dj": "pnpm run easy-changeset && pnpm changeset status",
1263
- "djv": "pnpm changeset version",
1264
- "generate-blog-index": "dev-scripts generate-blog-index -v",
1265
- "check-translations": "dev-scripts check-translations -v",
1266
- "clean-translations": "dev-scripts clean-translations -v",
1267
- "remove-translations": "dev-scripts clean-translations --remove -v",
1268
- "whoareyou": "dev-scripts generate-nextjs-architecture -v"
1269
- };
1276
+ if (pkg.devDependencies) {
1277
+ Object.keys(pkg.devDependencies).forEach((key) => {
1278
+ if (key.startsWith("@windrun-huaiin/")) {
1279
+ pkg.devDependencies[key] = "workspace:^";
1280
+ }
1281
+ });
1282
+ }
1283
+ delete pkg.pnpm;
1284
+ if (pkg.scripts) {
1285
+ delete pkg.scripts["deep-clean"];
1286
+ delete pkg.scripts["d8"];
1287
+ delete pkg.scripts["easy-changeset"];
1288
+ delete pkg.scripts["dj"];
1289
+ delete pkg.scripts["djv"];
1290
+ delete pkg.scripts["djvp"];
1291
+ }
1292
+ } else {
1293
+ pkg.pnpm = {
1294
+ "onlyBuiltDependencies": [
1295
+ "@clerk/shared",
1296
+ "@parcel/watcher",
1297
+ "@tailwindcss/oxide",
1298
+ "core-js",
1299
+ "esbuild",
1300
+ "sharp",
1301
+ "unrs-resolver"
1302
+ ],
1303
+ "overrides": {
1304
+ "@types/react": "19.1.2",
1305
+ "@types/react-dom": "19.1.3"
1306
+ },
1307
+ "patchedDependencies": {
1308
+ "fumadocs-ui@15.3.3": "patches/fumadocs-ui@15.3.3.patch"
1309
+ }
1310
+ };
1311
+ if (pkg.scripts) {
1312
+ delete pkg.scripts["djvp"];
1313
+ }
1314
+ }
1270
1315
  delete pkg.publishConfig;
1271
1316
  delete pkg.files;
1272
1317
  await fsExtra.writeJson(pkgPath, pkg, { spaces: 2 });
1273
- console.log("Installing dependencies...");
1274
- try {
1275
- child_process.execSync("pnpm install", { cwd: destDir, stdio: "inherit" });
1276
- } catch (error) {
1277
- console.warn("pnpm failed, trying npm...");
1318
+ if (!skipInstallAndGit) {
1319
+ console.log("Installing dependencies...");
1278
1320
  try {
1279
- child_process.execSync("npm install", { cwd: destDir, stdio: "inherit" });
1280
- } catch (npmError) {
1281
- console.error("Failed to install dependencies. Please run npm install or pnpm install manually.");
1321
+ child_process.execSync("pnpm install", { cwd: destDir, stdio: "inherit" });
1322
+ } catch (error) {
1323
+ console.warn("pnpm failed, trying npm...");
1324
+ try {
1325
+ child_process.execSync("npm install", { cwd: destDir, stdio: "inherit" });
1326
+ } catch (npmError) {
1327
+ console.error("Failed to install dependencies. Please run npm install or pnpm install manually.");
1328
+ }
1282
1329
  }
1283
- }
1284
- console.log("Initializing Git repository...");
1285
- try {
1286
- child_process.execSync("git init", { cwd: destDir, stdio: "inherit" });
1287
- child_process.execSync("git add .", { cwd: destDir, stdio: "inherit" });
1288
- child_process.execSync('git commit -m "feat: initial commit from diaomao template"', { cwd: destDir, stdio: "inherit" });
1289
- } catch (error) {
1290
- console.warn("Failed to initialize Git repository. Please initialize manually.");
1330
+ console.log("Initializing Git repository...");
1331
+ try {
1332
+ child_process.execSync("git init", { cwd: destDir, stdio: "inherit" });
1333
+ child_process.execSync("git add .", { cwd: destDir, stdio: "inherit" });
1334
+ child_process.execSync('git commit -m "feat: initial commit from diaomao template"', { cwd: destDir, stdio: "inherit" });
1335
+ } catch (error) {
1336
+ console.warn("Failed to initialize Git repository. Please initialize manually.");
1337
+ }
1338
+ } else {
1339
+ console.log("Skipping dependency installation and Git initialization (managed by monorepo)");
1291
1340
  }
1292
1341
  console.log(`
1293
1342
  \u2705 Project created: ${destDir}`);
1294
1343
  console.log(`
1295
1344
  Next steps:`);
1296
- console.log(` cd ${targetDir}`);
1297
- console.log(` pnpm dev`);
1345
+ if (isMonorepo) {
1346
+ console.log(` Config pnpm-workspace.yaml, add your packages: -apps/${targetDir} for your monorepo`);
1347
+ console.log(` Config .changeset/d8-template.mdx for CHANGELOG`);
1348
+ console.log(` # Run 'pnpm install' from monorepo root if needed`);
1349
+ console.log(` pnpm build`);
1350
+ console.log(` pnpm dev`);
1351
+ } else {
1352
+ console.log(` cd ${targetDir}`);
1353
+ console.log(` pnpm build`);
1354
+ console.log(` pnpm dev`);
1355
+ }
1298
1356
  console.log(` NOTE: please check .env.local file and set your own env!`);
1299
1357
  } catch (error) {
1300
1358
  console.error("Failed to create project:", error);