@valuerail/cli 1.1.1 → 1.2.0-beta.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.
Files changed (2) hide show
  1. package/dist/index.js +90 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -50656,7 +50656,7 @@ import fs2 from "fs";
50656
50656
  import path from "path";
50657
50657
  var hasVrailConfig = () => {
50658
50658
  try {
50659
- return fs2.existsSync(path.join(process.cwd(), "vrail.config.ts"));
50659
+ return fs2.existsSync(path.join(process.cwd(), "vrail.json"));
50660
50660
  } catch {
50661
50661
  return false;
50662
50662
  }
@@ -50665,7 +50665,7 @@ function Banner({ hideStatus = false }) {
50665
50665
  const isVrailProject = hasVrailConfig();
50666
50666
  const [version, setVersion] = import_react26.useState("v0.0.1");
50667
50667
  import_react26.useEffect(() => {
50668
- const v = "1.1.1";
50668
+ const v = "1.2.0-beta.2";
50669
50669
  setVersion(v);
50670
50670
  }, []);
50671
50671
  return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(Box_default, {
@@ -52319,28 +52319,20 @@ function InitProject({ onComplete, onBack }) {
52319
52319
  let name = projectName.trim();
52320
52320
  if (!name)
52321
52321
  name = "my-app";
52322
- let targetPath;
52323
- let resolvedProjectName;
52324
- if (name === ".") {
52325
- targetPath = process.cwd();
52326
- resolvedProjectName = path3.basename(targetPath);
52327
- } else {
52328
- const sanitizedName = name.toLowerCase().replace(/[^a-z0-9-_]/g, "-");
52329
- targetPath = path3.join(process.cwd(), sanitizedName);
52330
- resolvedProjectName = sanitizedName;
52331
- }
52332
- if (name !== "." && fs8.existsSync(targetPath)) {
52333
- setError(`Directory "${resolvedProjectName}" already exists`);
52334
- return;
52335
- }
52336
- setActualProjectName(resolvedProjectName);
52337
- setTargetDir(targetPath);
52338
- setStep("creating");
52339
52322
  try {
52323
+ const result = resolveTargetPath(name);
52324
+ setActualProjectName(result.resolvedProjectName);
52325
+ setTargetDir(result.targetPath);
52326
+ if (name !== "." && fs8.existsSync(result.targetPath)) {
52327
+ setError(`Directory "${result.resolvedProjectName}" already exists`);
52328
+ return;
52329
+ }
52330
+ setStep("creating");
52340
52331
  const __filename2 = fileURLToPath2(import.meta.url);
52341
52332
  const __dirname3 = path3.dirname(__filename2);
52342
52333
  const templatePath = path3.join(__dirname3, "..", "templates", "nextjs");
52343
- await copyTemplate(templatePath, targetPath, resolvedProjectName);
52334
+ await copyTemplate(templatePath, result.targetPath, result.resolvedProjectName);
52335
+ createVrailJson(result.targetPath);
52344
52336
  setStep("selection");
52345
52337
  } catch (err) {
52346
52338
  setError(err instanceof Error ? err.message : "Unknown error");
@@ -52648,6 +52640,28 @@ function InitProject({ onComplete, onBack }) {
52648
52640
  }
52649
52641
  return null;
52650
52642
  }
52643
+ function resolveTargetPath(name) {
52644
+ let targetPath;
52645
+ let resolvedProjectName;
52646
+ if (name === ".") {
52647
+ targetPath = process.cwd();
52648
+ resolvedProjectName = path3.basename(targetPath);
52649
+ } else {
52650
+ const sanitizedName = name.toLowerCase().replace(/[^a-z0-9-_]/g, "-");
52651
+ targetPath = path3.join(process.cwd(), sanitizedName);
52652
+ resolvedProjectName = sanitizedName;
52653
+ }
52654
+ return { targetPath, resolvedProjectName };
52655
+ }
52656
+ function createVrailJson(targetPath) {
52657
+ const configPath = path3.join(targetPath, "vrail.json");
52658
+ if (!fs8.existsSync(configPath)) {
52659
+ fs8.writeFileSync(configPath, JSON.stringify({
52660
+ version: "1.0.0",
52661
+ modules: []
52662
+ }, null, 4));
52663
+ }
52664
+ }
52651
52665
  async function copyTemplate(src, dest, projectName) {
52652
52666
  if (!fs8.existsSync(dest)) {
52653
52667
  fs8.mkdirSync(dest, { recursive: true });
@@ -52769,7 +52783,7 @@ function App2() {
52769
52783
  onBack: goToDashboard
52770
52784
  }, undefined, false, undefined, this),
52771
52785
  currentView === "goodbye" && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(GoodbyeView, {
52772
- version: "1.1.1",
52786
+ version: "1.2.0-beta.2",
52773
52787
  cwd: process.cwd(),
52774
52788
  isVrailProject: hasVrailConfig2()
52775
52789
  }, undefined, false, undefined, this)
@@ -52781,6 +52795,9 @@ function App2() {
52781
52795
 
52782
52796
  // src/index.tsx
52783
52797
  var jsx_dev_runtime12 = __toESM(require_jsx_dev_runtime(), 1);
52798
+ import path5 from "path";
52799
+ import fs10 from "fs";
52800
+ import { fileURLToPath as fileURLToPath3 } from "url";
52784
52801
  process.on("uncaughtException", (err) => {
52785
52802
  console.error("Uncaught Exception:", err);
52786
52803
  process.exit(1);
@@ -52789,5 +52806,57 @@ process.on("unhandledRejection", (reason, promise) => {
52789
52806
  console.error("Unhandled Rejection at:", promise, "reason:", reason);
52790
52807
  process.exit(1);
52791
52808
  });
52809
+ var args = process.argv.slice(2);
52810
+ var command = args[0];
52811
+ var showHelp = () => {
52812
+ console.log(`
52813
+ Usage: vrail [command] [options]
52814
+
52815
+ Commands:
52816
+ init [path] Initialize a new ValueRail project in the specified path
52817
+ help Show this help message
52818
+ -v, --version Show version
52819
+
52820
+ If no command is provided, the interactive dashboard will start.
52821
+ `);
52822
+ };
52823
+ var showVersion = () => {
52824
+ console.log("1.2.0-beta.2");
52825
+ };
52826
+ if (command === "help" || command === "--help" || command === "-h") {
52827
+ showHelp();
52828
+ process.exit(0);
52829
+ }
52830
+ if (command === "-v" || command === "--version") {
52831
+ showVersion();
52832
+ process.exit(0);
52833
+ }
52834
+ if (command === "init") {
52835
+ const target = args[1] || "my-app";
52836
+ const { targetPath, resolvedProjectName } = resolveTargetPath(target);
52837
+ if (target !== "." && fs10.existsSync(targetPath)) {
52838
+ console.error(`✘ Error: Directory "${resolvedProjectName}" already exists`);
52839
+ process.exit(1);
52840
+ }
52841
+ console.log(`\uD83D\uDE80 Initializing ValueRail project in ${targetPath}...`);
52842
+ try {
52843
+ const __filename2 = fileURLToPath3(import.meta.url);
52844
+ const __dirname3 = path5.dirname(__filename2);
52845
+ const templatePath = path5.join(__dirname3, "..", "templates", "nextjs");
52846
+ await copyTemplate(templatePath, targetPath, resolvedProjectName);
52847
+ createVrailJson(targetPath);
52848
+ console.log(`✔ Project initialized successfully!`);
52849
+ console.log(`
52850
+ Next steps:`);
52851
+ if (target !== ".")
52852
+ console.log(` cd ${resolvedProjectName}`);
52853
+ console.log(` bun install`);
52854
+ console.log(` bun dev`);
52855
+ process.exit(0);
52856
+ } catch (err) {
52857
+ console.error(`✘ Error during initialization:`, err instanceof Error ? err.message : err);
52858
+ process.exit(1);
52859
+ }
52860
+ }
52792
52861
  var { waitUntilExit } = render_default(/* @__PURE__ */ jsx_dev_runtime12.jsxDEV(App2, {}, undefined, false, undefined, this));
52793
52862
  await waitUntilExit();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valuerail/cli",
3
- "version": "1.1.1",
3
+ "version": "1.2.0-beta.2",
4
4
  "author": "Kamil Guszpit",
5
5
  "license": "BUSL-1.1",
6
6
  "type": "module",