@jagoankode/api-client 1.0.0 → 1.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/init.js CHANGED
@@ -5603,18 +5603,23 @@ program2.command("init").description("Initialize the API Tester route in your Ne
5603
5603
  const route = options.route || "http-client";
5604
5604
  const cwd = process.cwd();
5605
5605
  console.log("\nSetting up Next.js API Tester...\n");
5606
- const appDir = import_node_path2.default.join(cwd, "app");
5606
+ let appDir = import_node_path2.default.join(cwd, "app");
5607
+ let isSrcApp = false;
5607
5608
  if (!import_fs_extra.default.existsSync(appDir)) {
5608
- console.error(
5609
- "Error: app/ directory not found. Make sure you're in a Next.js App Router project."
5610
- );
5611
- process.exit(1);
5609
+ appDir = import_node_path2.default.join(cwd, "src", "app");
5610
+ if (!import_fs_extra.default.existsSync(appDir)) {
5611
+ console.error(
5612
+ "Error: app/ or src/app/ directory not found. Make sure you're in a Next.js App Router project."
5613
+ );
5614
+ process.exit(1);
5615
+ }
5616
+ isSrcApp = true;
5612
5617
  }
5613
5618
  const routeDir = import_node_path2.default.join(appDir, route);
5614
5619
  import_fs_extra.default.ensureDirSync(routeDir);
5615
5620
  const pageContent = `"use client";
5616
5621
 
5617
- import { ApiTester } from "api-client";
5622
+ import { ApiTester } from "@jagoankode/api-client";
5618
5623
 
5619
5624
  export default function ApiTesterPage() {
5620
5625
  return <ApiTester />;
@@ -5622,9 +5627,10 @@ export default function ApiTesterPage() {
5622
5627
  `;
5623
5628
  const pagePath = import_node_path2.default.join(routeDir, "page.tsx");
5624
5629
  import_fs_extra.default.writeFileSync(pagePath, pageContent, "utf-8");
5625
- console.log(`Created app/${route}/page.tsx`);
5630
+ console.log(`Created ${isSrcApp ? "src/app" : "app"}/${route}/page.tsx`);
5626
5631
  const gitignorePath = import_node_path2.default.join(cwd, ".gitignore");
5627
- const gitignoreLine = `/app/${route}`;
5632
+ const appPathPrefix = isSrcApp ? "/src/app" : "/app";
5633
+ const gitignoreLine = `${appPathPrefix}/${route}`;
5628
5634
  if (import_fs_extra.default.existsSync(gitignorePath)) {
5629
5635
  const content = import_fs_extra.default.readFileSync(gitignorePath, "utf-8");
5630
5636
  if (!content.includes(gitignoreLine)) {