@buba_71/levit 0.3.2 → 0.3.3

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/README.md CHANGED
@@ -57,16 +57,24 @@ These limits are intentional.
57
57
  Levit-kit is used **once**, at the very beginning of a project.
58
58
 
59
59
  ```bash
60
- npx levit init my-project
60
+ npx @buba_71/levit init my-project
61
61
  ```
62
62
 
63
- This command:
64
- - creates a new project directory
65
- - copies the default levit-kit template
66
- - installs no dependency
67
- - exits immediately
63
+ ### Commands & Options
68
64
 
69
- Levit-kit does not remain in the project after initialization.
65
+ - `init <name>`: Initializes a new project in the specified directory.
66
+ - `-v, --version`: Displays the current version.
67
+ - `-h, --help`: Displays the help message.
68
+
69
+ ### What happens during init?
70
+
71
+ The `init` command:
72
+ 1. Creates a new project directory.
73
+ 2. Copies the **default levit-kit template**.
74
+ 3. Includes a base `.gitignore` and `package.json`.
75
+ 4. Exits immediately.
76
+
77
+ Levit-kit does not remain in the project after initialization and installs no dependencies.
70
78
 
71
79
  ---
72
80
 
package/dist/bin/cli.js CHANGED
@@ -6,19 +6,62 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const init_1 = require("../src/init");
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
+ const fs_extra_1 = __importDefault(require("fs-extra"));
10
+ function getVersion() {
11
+ try {
12
+ const packageJson = fs_extra_1.default.readJsonSync(node_path_1.default.join(__dirname, "..", "..", "package.json"));
13
+ return packageJson.version;
14
+ }
15
+ catch {
16
+ return "unknown";
17
+ }
18
+ }
19
+ function showHelp() {
20
+ console.log(`
21
+ Usage: levit [command] [options]
22
+
23
+ Commands:
24
+ init <project-name> Initialize a new levit project
25
+
26
+ Options:
27
+ -v, --version Show version number
28
+ -h, --help Show help
29
+ `);
30
+ }
9
31
  function main() {
10
32
  const args = process.argv.slice(2);
11
- if (args.length !== 2 || args[0] !== "init") {
12
- console.error("Usage: levit init <project-name>");
13
- process.exit(1);
33
+ if (args.includes("-h") || args.includes("--help") || args.length === 0) {
34
+ showHelp();
35
+ process.exit(0);
14
36
  }
15
- const projectName = args[1];
16
- const targetPath = node_path_1.default.resolve(process.cwd(), projectName);
17
- try {
18
- (0, init_1.initProject)(projectName, targetPath);
37
+ if (args.includes("-v") || args.includes("--version")) {
38
+ console.log(`levit-kit v${getVersion()}`);
39
+ process.exit(0);
40
+ }
41
+ if (args[0] === "init") {
42
+ const projectName = args[1];
43
+ if (!projectName) {
44
+ console.error("Error: Project name is required.");
45
+ console.error("Usage: levit init <project-name>");
46
+ process.exit(1);
47
+ }
48
+ // Basic validation: ensure it's a valid directory name
49
+ if (!/^[a-z0-9-_]+$/i.test(projectName)) {
50
+ console.error("Error: Invalid project name. Use only letters, numbers, dashes, and underscores.");
51
+ process.exit(1);
52
+ }
53
+ const targetPath = node_path_1.default.resolve(process.cwd(), projectName);
54
+ try {
55
+ (0, init_1.initProject)(projectName, targetPath);
56
+ }
57
+ catch (error) {
58
+ console.error(error instanceof Error ? `Error: ${error.message}` : "Unexpected error");
59
+ process.exit(1);
60
+ }
19
61
  }
20
- catch (error) {
21
- console.error(error instanceof Error ? error.message : "Unexpected error");
62
+ else {
63
+ console.error(`Error: Unknown command "${args[0]}"`);
64
+ showHelp();
22
65
  process.exit(1);
23
66
  }
24
67
  }
package/dist/src/init.js CHANGED
@@ -4,51 +4,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.initProject = initProject;
7
- const node_fs_1 = __importDefault(require("node:fs"));
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  function getPackageRoot() {
10
10
  // Use __dirname to reliably locate the package root relative to this file
11
11
  // compiled file is in dist/src/init.js, so we go up two levels to reach package root
12
12
  return node_path_1.default.resolve(__dirname, "..", "..");
13
13
  }
14
+ function getVersion() {
15
+ try {
16
+ const packageJson = fs_extra_1.default.readJsonSync(node_path_1.default.join(getPackageRoot(), "package.json"));
17
+ return packageJson.version;
18
+ }
19
+ catch {
20
+ return "0.0.0";
21
+ }
22
+ }
14
23
  function initProject(projectName, targetPath) {
15
24
  const packageRoot = getPackageRoot();
16
25
  const templatePath = node_path_1.default.join(packageRoot, "templates", "default");
26
+ const version = getVersion();
17
27
  if (!projectName) {
18
28
  throw new Error("Project name is required.");
19
29
  }
20
- if (node_fs_1.default.existsSync(targetPath)) {
30
+ if (fs_extra_1.default.existsSync(targetPath)) {
21
31
  throw new Error(`Directory "${projectName}" already exists.`);
22
32
  }
23
- if (!node_fs_1.default.existsSync(templatePath)) {
33
+ if (!fs_extra_1.default.existsSync(templatePath)) {
24
34
  throw new Error(`Default template not found at ${templatePath}`);
25
35
  }
26
- node_fs_1.default.mkdirSync(targetPath, { recursive: true });
27
- copyDirectory(templatePath, targetPath);
36
+ fs_extra_1.default.ensureDirSync(targetPath);
37
+ fs_extra_1.default.copySync(templatePath, targetPath);
28
38
  console.log("");
29
- console.log("levit-kit v1.0");
39
+ console.log(`🚀 levit-kit v${version}`);
30
40
  console.log("");
31
- console.log("✔ Project directory created");
32
- console.log("✔ Template copied");
41
+ console.log(" ✔ Project directory created");
42
+ console.log(" ✔ Template copied");
33
43
  console.log("");
34
- console.log(`Project "${projectName}" initialized successfully.`);
44
+ console.log(`✨ Project "${projectName}" initialized successfully.`);
35
45
  console.log("");
36
46
  console.log("Next steps:");
37
- console.log(" - Open the project");
47
+ console.log(` - cd ${projectName}`);
38
48
  console.log(" - Read SOCIAL_CONTRACT.md");
39
49
  console.log(" - Start defining features");
40
- }
41
- function copyDirectory(source, target) {
42
- const entries = node_fs_1.default.readdirSync(source, { withFileTypes: true });
43
- for (const entry of entries) {
44
- const sourcePath = node_path_1.default.join(source, entry.name);
45
- const targetPath = node_path_1.default.join(target, entry.name);
46
- if (entry.isDirectory()) {
47
- node_fs_1.default.mkdirSync(targetPath, { recursive: true });
48
- copyDirectory(sourcePath, targetPath);
49
- }
50
- else {
51
- node_fs_1.default.copyFileSync(sourcePath, targetPath);
52
- }
53
- }
50
+ console.log("");
54
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buba_71/levit",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Hybrid starter kit for Antigravity projects",
5
5
  "author": "David BUBA",
6
6
  "license": "MIT",
File without changes