@kithinji/pod 1.0.49 → 1.0.51

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
@@ -3871,8 +3871,10 @@ function useMyPlugin(options) {
3871
3871
  }
3872
3872
  const node = options.graph[args.path];
3873
3873
  if (!node) {
3874
- console.log(`File node not found in depend graph: ${args.path}`);
3875
- throw new Error("900");
3874
+ console.log(JSON.stringify(options.graph, null, 2));
3875
+ throw new Error(
3876
+ `File node not found in depend graph: ${args.path}`
3877
+ );
3876
3878
  }
3877
3879
  return clientTransformer.process(node, metadata);
3878
3880
  }
@@ -3896,52 +3898,39 @@ function findProjectRoot(startPath) {
3896
3898
  }
3897
3899
  return process.cwd();
3898
3900
  }
3899
- function resolvePathAlias(importPath, projectRoot) {
3900
- if (importPath.startsWith("@/")) {
3901
- const possiblePaths = [
3902
- path7.join(projectRoot, "src", importPath.slice(2)),
3903
- path7.join(projectRoot, importPath.slice(2))
3904
- ];
3905
- for (const possiblePath of possiblePaths) {
3906
- const extensions = ["", ".ts", ".tsx", ".js", ".jsx"];
3907
- for (const ext of extensions) {
3908
- const fullPath = possiblePath + ext;
3909
- if (fs3.existsSync(fullPath) && fs3.statSync(fullPath).isFile()) {
3910
- return fullPath;
3911
- }
3912
- }
3913
- const indexFiles = ["/index.ts", "/index.tsx", "/index.js", "/index.jsx"];
3914
- for (const indexFile of indexFiles) {
3915
- const fullPath = possiblePath + indexFile;
3916
- if (fs3.existsSync(fullPath) && fs3.statSync(fullPath).isFile()) {
3917
- return fullPath;
3918
- }
3919
- }
3901
+ function tryResolveWithExtensions(basePath) {
3902
+ const extensions = [".ts", ".tsx", ".js", ".jsx"];
3903
+ for (const ext of ["", ...extensions]) {
3904
+ const fullPath = basePath + ext;
3905
+ if (fs3.existsSync(fullPath) && fs3.statSync(fullPath).isFile()) {
3906
+ return fullPath;
3907
+ }
3908
+ }
3909
+ for (const ext of extensions) {
3910
+ const indexPath = path7.join(basePath, `index${ext}`);
3911
+ if (fs3.existsSync(indexPath) && fs3.statSync(indexPath).isFile()) {
3912
+ return indexPath;
3920
3913
  }
3921
3914
  }
3922
3915
  return null;
3923
3916
  }
3924
3917
  function resolveFilePath(fromFile, importPath) {
3918
+ const projectRoot = findProjectRoot(fromFile);
3925
3919
  if (importPath.startsWith("@/")) {
3926
- const projectRoot = findProjectRoot(fromFile);
3927
- const aliasResolved = resolvePathAlias(importPath, projectRoot);
3928
- if (aliasResolved) return aliasResolved;
3929
- }
3930
- if (!importPath.startsWith(".")) return null;
3931
- const dir = path7.dirname(fromFile);
3932
- const basePath = path7.resolve(dir, importPath);
3933
- const extensions = ["", ".ts", ".tsx", ".js", ".jsx"];
3934
- for (const ext of extensions) {
3935
- const fullPath = basePath + ext;
3936
- if (fs3.existsSync(fullPath) && fs3.statSync(fullPath).isFile())
3937
- return fullPath;
3938
- }
3939
- const indexFiles = ["/index.ts", "/index.tsx", "/index.js", "/index.jsx"];
3940
- for (const indexFile of indexFiles) {
3941
- const fullPath = basePath + indexFile;
3942
- if (fs3.existsSync(fullPath) && fs3.statSync(fullPath).isFile())
3943
- return fullPath;
3944
- }
3920
+ const base = path7.join(projectRoot, "src", importPath.slice(2));
3921
+ return tryResolveWithExtensions(base);
3922
+ }
3923
+ if (importPath.startsWith(".")) {
3924
+ const dir = path7.dirname(fromFile);
3925
+ const base = path7.resolve(dir, importPath);
3926
+ return tryResolveWithExtensions(base);
3927
+ }
3928
+ const rootBased = path7.join(projectRoot, importPath);
3929
+ const resolvedRoot = tryResolveWithExtensions(rootBased);
3930
+ if (resolvedRoot) return resolvedRoot;
3931
+ const srcBased = path7.join(projectRoot, "src", importPath);
3932
+ const resolvedSrc = tryResolveWithExtensions(srcBased);
3933
+ if (resolvedSrc) return resolvedSrc;
3945
3934
  return null;
3946
3935
  }
3947
3936
  function extractDecorators(decorators) {
@@ -4722,7 +4711,7 @@ async function startDevServer() {
4722
4711
  }
4723
4712
  await serverCtx.watch();
4724
4713
  }
4725
- async function startBuild() {
4714
+ async function startBuild(start = false) {
4726
4715
  const logger = createLogger(false);
4727
4716
  const store = Store.getInstance();
4728
4717
  logger.info("Starting production build...");
@@ -4786,6 +4775,30 @@ async function startBuild() {
4786
4775
  }
4787
4776
  logger.info("Production build completed successfully!");
4788
4777
  logger.info(`Output: dist/${hasClientFiles ? " and public/" : ""}`);
4778
+ if (start) {
4779
+ logger.info("Starting production server...");
4780
+ const serverProcess = spawn("node", ["dist/main.js"], {
4781
+ stdio: "inherit"
4782
+ });
4783
+ serverProcess.on("error", (err) => {
4784
+ logger.error("Server process error:", err);
4785
+ process.exit(1);
4786
+ });
4787
+ serverProcess.on("exit", (code) => {
4788
+ if (code !== null && code !== 0) {
4789
+ logger.error(`Server process exited with code ${code}`);
4790
+ process.exit(code);
4791
+ }
4792
+ });
4793
+ const shutdown = async () => {
4794
+ logger.info("Shutting down production server...");
4795
+ await waitForProcessExit(serverProcess);
4796
+ process.exit(0);
4797
+ };
4798
+ process.on("SIGINT", shutdown);
4799
+ process.on("SIGTERM", shutdown);
4800
+ logger.info("Production server started successfully!");
4801
+ }
4789
4802
  } catch (error) {
4790
4803
  logger.error("Build failed:", error);
4791
4804
  process.exit(1);
@@ -7514,7 +7527,7 @@ async function compileFiles(entryPoints) {
7514
7527
 
7515
7528
  // src/index.ts
7516
7529
  var program = new Command();
7517
- program.name("pod").description("Pod cli tool").version("1.0.46");
7530
+ program.name("pod").description("Pod cli tool").version("1.0.51");
7518
7531
  program.command("new <name> [type]").description("Start a new Orca Project").action(async (name, type) => {
7519
7532
  const orca = async () => {
7520
7533
  await addNew(name);
@@ -7550,6 +7563,9 @@ program.command("dev").description("Start Pod development server").action(async
7550
7563
  program.command("build").description("Start Pod build").action(async (opts) => {
7551
7564
  await startBuild();
7552
7565
  });
7566
+ program.command("start").description("Start Pod build").action(async (opts) => {
7567
+ await startBuild(true);
7568
+ });
7553
7569
  program.command("compile <files...>").description("Compile ts files with pod").action(async (files) => {
7554
7570
  await compileFiles(files);
7555
7571
  });