@yusr_systems/cli 2.0.0 → 2.0.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @yusr_systems/cli
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - add the ability to change perm format
8
+
3
9
  ## 2.0.0
4
10
 
5
11
  ### Major Changes
package/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { program } = require('commander');
4
- const execa = require('execa');
5
- const fs = require('fs-extra');
6
- const path = require('path');
7
- const chalk = require('chalk');
8
- const inquirer = require('inquirer');
3
+ import { program } from 'commander';
4
+ import execa from 'execa';
5
+ import fs from 'fs-extra';
6
+ import path from 'path';
7
+ import chalk from 'chalk';
8
+ import inquirer from 'inquirer';
9
+
9
10
 
10
11
  program
11
12
  .version('1.0.0')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yusr_systems/cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "CLI to initialize Yusr Systems environment",
5
5
  "private": false,
6
6
  "type": "module",
@@ -8,11 +8,14 @@
8
8
  "access": "public",
9
9
  "registry": "https://registry.npmjs.org/"
10
10
  },
11
- "main": "index.js",
11
+ "main": "./dist/index.js",
12
12
  "bin": {
13
- "yusr-init": "./index.js"
13
+ "yusr-init": "./dist/index.js"
14
14
  },
15
15
  "scripts": {
16
+ "build": "tsup src/index.ts --format esm --clean --minify",
17
+ "dev": "tsup src/index.ts --format esm --watch",
18
+ "start": "node dist/index.js",
16
19
  "test": "echo \"Error: no test specified\" && exit 1"
17
20
  },
18
21
  "keywords": [
@@ -24,9 +27,16 @@
24
27
  "license": "ISC",
25
28
  "dependencies": {
26
29
  "chalk": "^4.1.2",
27
- "commander": "^11.0.0",
30
+ "commander": "^11.1.0",
28
31
  "execa": "^5.1.1",
29
- "fs-extra": "^11.1.1",
32
+ "fs-extra": "^11.3.4",
30
33
  "inquirer": "^8.2.7"
34
+ },
35
+ "devDependencies": {
36
+ "@types/fs-extra": "^11.0.4",
37
+ "@types/inquirer": "^9.0.9",
38
+ "@types/node": "^25.5.0",
39
+ "tsup": "^8.5.1",
40
+ "typescript": "^5.9.3"
31
41
  }
32
42
  }
package/src/index.ts ADDED
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { program } from "commander";
4
+ import execa from "execa";
5
+ import fs from "fs-extra";
6
+ import path from "path";
7
+ import chalk from "chalk";
8
+ import inquirer from "inquirer";
9
+ import os from "os";
10
+ import YusrDefaultCss from "./yusr_default_code/yusr_default_css";
11
+
12
+ interface ProjectAnswers {
13
+ projectName: string;
14
+ framework: "Next.js" | "Vite (React)";
15
+ }
16
+
17
+ program.version("1.0.0").description("Yusr Systems Project Initializer");
18
+
19
+ program
20
+ .command("create")
21
+ .description("Create a new project using the Yusr environment")
22
+ .action(async (): Promise<void> => {
23
+ try {
24
+ const answers: ProjectAnswers = await inquirer.prompt([
25
+ {
26
+ type: "input",
27
+ name: "projectName",
28
+ message: "What is your project name?",
29
+ default: "my-yusr-app",
30
+ },
31
+ {
32
+ type: "list",
33
+ name: "framework",
34
+ message: "Which framework would you like to use?",
35
+ choices: ["Next.js", "Vite (React)"],
36
+ },
37
+ ]);
38
+
39
+ const { projectName, framework } = answers;
40
+ const finalDestination = path.resolve(process.cwd(), projectName);
41
+
42
+ // Extract a safe folder name
43
+ const safeName = path.basename(finalDestination);
44
+
45
+ // 1. SAFE CLEANUP
46
+ if (await fs.pathExists(finalDestination)) {
47
+ const { overwrite } = await inquirer.prompt([
48
+ {
49
+ type: "confirm",
50
+ name: "overwrite",
51
+ message: chalk.red(
52
+ `⚠️ Directory "${projectName}" already exists. Overwrite it?`,
53
+ ),
54
+ default: false,
55
+ },
56
+ ]);
57
+
58
+ if (!overwrite) {
59
+ console.log(chalk.yellow("❌ Initialization aborted."));
60
+ process.exit(1);
61
+ }
62
+ await fs.remove(finalDestination);
63
+ }
64
+
65
+ console.log(
66
+ chalk.blue.bold(`\n🚀 Initializing your ${framework} project...`),
67
+ );
68
+
69
+ // 2. CREATE A TEMPORARY DIRECTORY
70
+ const tempDir = path.join(os.tmpdir(), `yusr-init-${Date.now()}`);
71
+ await fs.ensureDir(tempDir);
72
+
73
+ try {
74
+ const template = framework === "Next.js" ? "next" : "vite";
75
+
76
+ // 3. RUN SHADCN IN THE TEMP DIRECTORY
77
+ // Using your discovered flags: -n, -d, -b radix, and --no-monorepo
78
+ await execa(
79
+ "npx",
80
+ [
81
+ "shadcn@latest",
82
+ "init",
83
+ "-t",
84
+ template,
85
+ "-n",
86
+ safeName,
87
+ "-b",
88
+ "radix",
89
+ "-d",
90
+ "--no-monorepo",
91
+ "--preset",
92
+ "nova",
93
+ "--rtl",
94
+ ],
95
+ {
96
+ cwd: tempDir,
97
+ stdio: "inherit",
98
+ },
99
+ );
100
+
101
+ // 4. MOVE THE PROJECT TO THE FINAL DESTINATION
102
+ const createdProjectPath = path.join(tempDir, safeName);
103
+ await fs.move(createdProjectPath, finalDestination);
104
+
105
+ console.log(chalk.green("\n✅ Project created and configured."));
106
+ } finally {
107
+ // Always clean up the temp directory
108
+ await fs.remove(tempDir);
109
+ }
110
+
111
+ // 5. INSTALL YUSR PACKAGES
112
+ console.log(
113
+ chalk.yellow("\n📦 Installing @yusr_systems dependencies..."),
114
+ );
115
+ await execa(
116
+ "npm",
117
+ [
118
+ "install",
119
+ "@yusr_systems/ui",
120
+ "@yusr_systems/core",
121
+ "--legacy-peer-deps",
122
+ "@fontsource/ibm-plex-sans-arabic",
123
+ ],
124
+ {
125
+ cwd: finalDestination,
126
+ stdio: "inherit",
127
+ },
128
+ );
129
+ console.log(chalk.green("✅ Packages installed."));
130
+
131
+ // 6. FINAL CSS OVERRIDE
132
+ console.log(chalk.yellow("\n🛠️ Applying Yusr custom styles..."));
133
+
134
+ const cssPath =
135
+ framework === "Next.js"
136
+ ? path.join(finalDestination, "app/globals.css")
137
+ : path.join(finalDestination, "src/index.css");
138
+
139
+ const customCss = YusrDefaultCss.getDefaultCss(framework);
140
+ // Append our custom CSS to the bottom of the file
141
+ await fs.writeFile(cssPath, customCss);
142
+ console.log(chalk.green("✅ Styles applied."));
143
+
144
+ console.log(
145
+ chalk.green.bold(`\n✨ Success! Your project ${projectName} is ready.`),
146
+ );
147
+ console.log(
148
+ chalk.cyan(`\nNext steps:\n cd ${projectName}\n npm run dev\n`),
149
+ );
150
+ } catch (error: any) {
151
+ console.error(chalk.red("\n❌ An error occurred:"), error.message);
152
+ process.exit(1);
153
+ }
154
+ });
155
+
156
+ program.parse(process.argv);
package/src/types.ts ADDED
@@ -0,0 +1 @@
1
+ export type frameworkType = "Next.js" | "Vite (React)";
@@ -0,0 +1,35 @@
1
+ import { frameworkType } from "../types";
2
+
3
+ export default class YusrDefaultCss {
4
+ public static getDefaultCss(framework: frameworkType): string {
5
+ if (framework === "Vite (React)") return this._getViteCustomCss();
6
+
7
+ return this._getNextCustomCss();
8
+ }
9
+ private static _getViteCustomCss(): string {
10
+ return `
11
+ /* --- Yusr Auto Generated CSS Styles --- */
12
+ @import "tailwindcss";
13
+ @import "tw-animate-css";
14
+ @import "shadcn/tailwind.css";
15
+ @import "@fontsource/ibm-plex-sans-arabic/100.css";
16
+ @import "@fontsource/ibm-plex-sans-arabic/400.css";
17
+ @import "@fontsource/ibm-plex-sans-arabic/700.css";
18
+ @import "@yusr_systems/ui/style.css";
19
+ @source "../node_modules/@yusr_systems/ui/dist/yusr-ui.js";
20
+ `;
21
+ }
22
+
23
+ private static _getNextCustomCss(): string {
24
+ return `
25
+ /* --- Yusr Auto Generated CSS Styles --- */
26
+ @import "tailwindcss";
27
+ @import "shadcn/tailwind.css";
28
+ @import "@fontsource/ibm-plex-sans-arabic/100.css";
29
+ @import "@fontsource/ibm-plex-sans-arabic/400.css";
30
+ @import "@fontsource/ibm-plex-sans-arabic/700.css";
31
+ @import "@yusr_systems/ui/style.css";
32
+ @source "../node_modules/@yusr_systems/ui/dist/yusr-ui.js";
33
+ `;
34
+ }
35
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "strict": true,
6
+ "esModuleInterop": true,
7
+ "skipLibCheck": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "outDir": "dist"
10
+ },
11
+ "include": ["src/**/*"]
12
+ }