@unciatech/file-manager 0.0.31 → 0.0.32

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 (3) hide show
  1. package/dist/cli.cjs +81 -92
  2. package/dist/cli.js +76 -87
  3. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -24,20 +24,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  ));
25
25
 
26
26
  // cli.ts
27
- var import_fs = __toESM(require("fs"), 1);
28
- var import_path = __toESM(require("path"), 1);
27
+ var fs = __toESM(require("fs"), 1);
28
+ var path = __toESM(require("path"), 1);
29
29
  var import_child_process = require("child_process");
30
- var import_readline = __toESM(require("readline"), 1);
30
+ var readline = __toESM(require("readline"), 1);
31
31
  var args = process.argv.slice(2);
32
32
  var command = args[0];
33
33
  var projectName = args[1];
34
- var rl = import_readline.default.createInterface({
34
+ var rl = readline.createInterface({
35
35
  input: process.stdin,
36
36
  output: process.stdout
37
37
  });
38
- var askQuestion = (query) => {
39
- return new Promise((resolve) => rl.question(query, resolve));
40
- };
38
+ var askQuestion = (query) => new Promise((resolve) => rl.question(query, resolve));
41
39
  var TEMPLATE = `"use client";
42
40
 
43
41
  import React, { Suspense, useMemo } from "react";
@@ -65,35 +63,30 @@ async function main() {
65
63
  process.exit(0);
66
64
  }
67
65
  if (!projectName) {
68
- console.log("\u{1F680} Generating <FileManagerDemo /> component in the current project...");
66
+ console.log("\u{1F680} Generating <FileManagerDemo /> component...");
69
67
  let targetDir2 = process.cwd();
70
- if (import_fs.default.existsSync(import_path.default.join(process.cwd(), "components"))) {
71
- targetDir2 = import_path.default.join(process.cwd(), "components");
72
- } else if (import_fs.default.existsSync(import_path.default.join(process.cwd(), "src", "components"))) {
73
- targetDir2 = import_path.default.join(process.cwd(), "src", "components");
74
- }
75
- const targetFile = import_path.default.join(targetDir2, "FileManagerDemo.tsx");
76
- if (import_fs.default.existsSync(targetFile)) {
77
- console.error(`\u274C Error: ${targetFile} already exists.`);
78
- process.exit(1);
68
+ if (fs.existsSync(path.join(process.cwd(), "src/components"))) {
69
+ targetDir2 = path.join(process.cwd(), "src/components");
70
+ } else if (fs.existsSync(path.join(process.cwd(), "components"))) {
71
+ targetDir2 = path.join(process.cwd(), "components");
79
72
  }
80
- import_fs.default.writeFileSync(targetFile, TEMPLATE, "utf-8");
81
- console.log(`\u2705 Success! Created ${targetFile}`);
73
+ const file = path.join(targetDir2, "FileManagerDemo.tsx");
74
+ fs.writeFileSync(file, TEMPLATE);
75
+ console.log(`\u2705 Created ${file}`);
82
76
  process.exit(0);
83
77
  }
84
78
  console.log(`
85
- \u{1F680} Initializing a new application: ${projectName}
79
+ \u{1F680} Initializing project: ${projectName}
86
80
  `);
87
- console.log("Which framework would you like to use?");
88
- console.log(" 1) Next.js (App Router, Tailwind v4)");
89
- console.log(" 2) Vite (React, Tailwind v4)");
90
- console.log(" 3) Cancel");
91
- const choice = await askQuestion("\nSelect an option (1-3): ");
81
+ console.log("Choose framework:");
82
+ console.log("1) Next.js");
83
+ console.log("2) Vite (React)");
84
+ console.log("3) Cancel");
85
+ const choice = await askQuestion("\nSelect option (1-3): ");
92
86
  rl.close();
93
- const targetDir = import_path.default.join(process.cwd(), projectName);
94
- if (import_fs.default.existsSync(targetDir)) {
95
- console.error(`
96
- \u274C Error: Directory "${projectName}" already exists.`);
87
+ const targetDir = path.join(process.cwd(), projectName);
88
+ if (fs.existsSync(targetDir)) {
89
+ console.error("\u274C Directory already exists");
97
90
  process.exit(1);
98
91
  }
99
92
  try {
@@ -103,24 +96,32 @@ async function main() {
103
96
  await scaffoldVite(projectName, targetDir);
104
97
  } else {
105
98
  console.log("Canceled.");
106
- process.exit(0);
107
99
  }
108
- } catch (error) {
109
- console.error("\n\u274C Scaffolding failed:", error);
110
- process.exit(1);
100
+ } catch (e) {
101
+ console.error("\u274C Error:", e);
111
102
  }
112
- process.exit(0);
113
103
  }
114
104
  async function scaffoldNextjs(projectName2, targetDir) {
115
- console.log("\n\u{1F4E6} Creating Next.js application...");
116
- (0, import_child_process.execSync)(`npx create-next-app@latest ${projectName2} --ts --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm`, { stdio: "inherit" });
105
+ console.log("\n\u{1F4E6} Creating Next.js app...");
106
+ (0, import_child_process.execSync)(
107
+ `npx create-next-app@latest ${projectName2} --ts --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm`,
108
+ { stdio: "inherit" }
109
+ );
117
110
  console.log("\n\u{1F4E6} Installing dependencies...");
118
- (0, import_child_process.execSync)("npm install @unciatech/file-manager tailwindcss-animate", { cwd: targetDir, stdio: "inherit" });
119
- const componentsDir = import_path.default.join(targetDir, "src", "components");
120
- if (!import_fs.default.existsSync(componentsDir)) import_fs.default.mkdirSync(componentsDir, { recursive: true });
121
- import_fs.default.writeFileSync(import_path.default.join(componentsDir, "FileManagerDemo.tsx"), TEMPLATE, "utf-8");
122
- const pagePath = import_path.default.join(targetDir, "src", "app", "page.tsx");
123
- import_fs.default.writeFileSync(pagePath, `import FileManagerDemo from "@/components/FileManagerDemo";
111
+ (0, import_child_process.execSync)("npm install @unciatech/file-manager tailwindcss-animate", {
112
+ cwd: targetDir,
113
+ stdio: "inherit"
114
+ });
115
+ const componentsDir = path.join(targetDir, "src/components");
116
+ fs.mkdirSync(componentsDir, { recursive: true });
117
+ fs.writeFileSync(
118
+ path.join(componentsDir, "FileManagerDemo.tsx"),
119
+ TEMPLATE
120
+ );
121
+ const pagePath = path.join(targetDir, "src/app/page.tsx");
122
+ fs.writeFileSync(
123
+ pagePath,
124
+ `import FileManagerDemo from "@/components/FileManagerDemo";
124
125
 
125
126
  export default function Home() {
126
127
  return (
@@ -129,64 +130,51 @@ export default function Home() {
129
130
  </main>
130
131
  );
131
132
  }
132
- `);
133
+ `
134
+ );
133
135
  printSuccess(projectName2);
134
136
  }
135
137
  async function scaffoldVite(projectName2, targetDir) {
136
- console.log("\n\u{1F4E6} Creating Vite React application...");
137
- (0, import_child_process.execSync)(`npm create vite@latest ${projectName2} -- --template react-ts`, { stdio: "inherit" });
138
+ console.log("\n\u{1F4E6} Creating Vite app...");
139
+ (0, import_child_process.execSync)(
140
+ `npm create vite@latest ${projectName2} -- --template react-ts`,
141
+ { stdio: "inherit" }
142
+ );
138
143
  console.log("\n\u{1F4E6} Installing dependencies...");
139
144
  (0, import_child_process.execSync)("npm install", { cwd: targetDir, stdio: "inherit" });
140
145
  (0, import_child_process.execSync)(
141
- "npm install tailwindcss @tailwindcss/vite @unciatech/file-manager tw-animate-css",
146
+ "npm install tailwindcss @tailwindcss/vite tw-animate-css @unciatech/file-manager",
142
147
  { cwd: targetDir, stdio: "inherit" }
143
148
  );
144
- const viteConfigPath = import_path.default.join(targetDir, "vite.config.ts");
145
- import_fs.default.writeFileSync(
146
- viteConfigPath,
147
- `import { defineConfig } from 'vite'
149
+ const viteConfig = `import { defineConfig } from 'vite'
148
150
  import react from '@vitejs/plugin-react'
149
151
  import tailwindcss from '@tailwindcss/vite'
150
152
 
151
153
  export default defineConfig({
152
- plugins: [
153
- react(),
154
- tailwindcss(),
155
- ],
154
+ plugins: [react(), tailwindcss()],
156
155
  })
157
- `
158
- );
159
- const cssPath = import_path.default.join(targetDir, "src", "index.css");
160
- import_fs.default.writeFileSync(
161
- cssPath,
162
- `@import "tailwindcss";
156
+ `;
157
+ fs.writeFileSync(path.join(targetDir, "vite.config.ts"), viteConfig);
158
+ const css = `@import "tailwindcss";
163
159
  @import "tw-animate-css";
164
160
 
165
161
  @source "../node_modules/@unciatech/file-manager/dist/**/*.{js,ts,jsx,tsx}";
166
- `
167
- );
168
- const mainPath = import_path.default.join(targetDir, "src", "main.tsx");
169
- if (import_fs.default.existsSync(mainPath)) {
170
- let mainContent = import_fs.default.readFileSync(mainPath, "utf8");
171
- if (!mainContent.includes("@unciatech/file-manager/styles")) {
172
- mainContent = `import "@unciatech/file-manager/styles";
173
- ` + mainContent;
174
- import_fs.default.writeFileSync(mainPath, mainContent);
175
- }
176
- }
177
- const componentsDir = import_path.default.join(targetDir, "src", "components");
178
- if (!import_fs.default.existsSync(componentsDir)) {
179
- import_fs.default.mkdirSync(componentsDir, { recursive: true });
162
+ `;
163
+ fs.writeFileSync(path.join(targetDir, "src/index.css"), css);
164
+ const mainFile = path.join(targetDir, "src/main.tsx");
165
+ let main2 = fs.readFileSync(mainFile, "utf8");
166
+ if (!main2.includes("@unciatech/file-manager/styles")) {
167
+ main2 = `import "@unciatech/file-manager/styles";
168
+ ` + main2;
180
169
  }
181
- import_fs.default.writeFileSync(
182
- import_path.default.join(componentsDir, "FileManagerDemo.tsx"),
183
- TEMPLATE,
184
- "utf-8"
170
+ fs.writeFileSync(mainFile, main2);
171
+ const compDir = path.join(targetDir, "src/components");
172
+ fs.mkdirSync(compDir, { recursive: true });
173
+ fs.writeFileSync(
174
+ path.join(compDir, "FileManagerDemo.tsx"),
175
+ TEMPLATE
185
176
  );
186
- const appPath = import_path.default.join(targetDir, "src", "App.tsx");
187
- import_fs.default.writeFileSync(
188
- appPath,
189
- `import FileManagerDemo from "./components/FileManagerDemo";
177
+ const app = `import FileManagerDemo from "./components/FileManagerDemo";
190
178
 
191
179
  function App() {
192
180
  return (
@@ -197,17 +185,18 @@ function App() {
197
185
  }
198
186
 
199
187
  export default App;
200
- `
201
- );
188
+ `;
189
+ fs.writeFileSync(path.join(targetDir, "src/App.tsx"), app);
202
190
  printSuccess(projectName2);
203
191
  }
204
- function printSuccess(projectName2, devCmd = "npm run dev") {
205
- console.log("\n=========================================");
206
- console.log("\u{1F389} Your Media Library application is ready!");
207
- console.log("=========================================");
208
- console.log("\nNext steps:");
209
- console.log(` cd ${projectName2}`);
210
- console.log(` ${devCmd}`);
211
- console.log("\nEnjoy building! \u{1F5C2}\uFE0F\n");
192
+ function printSuccess(projectName2) {
193
+ console.log("\n=================================");
194
+ console.log("\u{1F389} Project ready!");
195
+ console.log("=================================");
196
+ console.log(`
197
+ Next steps:`);
198
+ console.log(`cd ${projectName2}`);
199
+ console.log(`npm run dev
200
+ `);
212
201
  }
213
202
  main();
package/dist/cli.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // cli.ts
4
- import fs from "fs";
5
- import path from "path";
4
+ import * as fs from "fs";
5
+ import * as path from "path";
6
6
  import { execSync } from "child_process";
7
- import readline from "readline";
7
+ import * as readline from "readline";
8
8
  var args = process.argv.slice(2);
9
9
  var command = args[0];
10
10
  var projectName = args[1];
@@ -12,9 +12,7 @@ var rl = readline.createInterface({
12
12
  input: process.stdin,
13
13
  output: process.stdout
14
14
  });
15
- var askQuestion = (query) => {
16
- return new Promise((resolve) => rl.question(query, resolve));
17
- };
15
+ var askQuestion = (query) => new Promise((resolve) => rl.question(query, resolve));
18
16
  var TEMPLATE = `"use client";
19
17
 
20
18
  import React, { Suspense, useMemo } from "react";
@@ -42,35 +40,30 @@ async function main() {
42
40
  process.exit(0);
43
41
  }
44
42
  if (!projectName) {
45
- console.log("\u{1F680} Generating <FileManagerDemo /> component in the current project...");
43
+ console.log("\u{1F680} Generating <FileManagerDemo /> component...");
46
44
  let targetDir2 = process.cwd();
47
- if (fs.existsSync(path.join(process.cwd(), "components"))) {
45
+ if (fs.existsSync(path.join(process.cwd(), "src/components"))) {
46
+ targetDir2 = path.join(process.cwd(), "src/components");
47
+ } else if (fs.existsSync(path.join(process.cwd(), "components"))) {
48
48
  targetDir2 = path.join(process.cwd(), "components");
49
- } else if (fs.existsSync(path.join(process.cwd(), "src", "components"))) {
50
- targetDir2 = path.join(process.cwd(), "src", "components");
51
49
  }
52
- const targetFile = path.join(targetDir2, "FileManagerDemo.tsx");
53
- if (fs.existsSync(targetFile)) {
54
- console.error(`\u274C Error: ${targetFile} already exists.`);
55
- process.exit(1);
56
- }
57
- fs.writeFileSync(targetFile, TEMPLATE, "utf-8");
58
- console.log(`\u2705 Success! Created ${targetFile}`);
50
+ const file = path.join(targetDir2, "FileManagerDemo.tsx");
51
+ fs.writeFileSync(file, TEMPLATE);
52
+ console.log(`\u2705 Created ${file}`);
59
53
  process.exit(0);
60
54
  }
61
55
  console.log(`
62
- \u{1F680} Initializing a new application: ${projectName}
56
+ \u{1F680} Initializing project: ${projectName}
63
57
  `);
64
- console.log("Which framework would you like to use?");
65
- console.log(" 1) Next.js (App Router, Tailwind v4)");
66
- console.log(" 2) Vite (React, Tailwind v4)");
67
- console.log(" 3) Cancel");
68
- const choice = await askQuestion("\nSelect an option (1-3): ");
58
+ console.log("Choose framework:");
59
+ console.log("1) Next.js");
60
+ console.log("2) Vite (React)");
61
+ console.log("3) Cancel");
62
+ const choice = await askQuestion("\nSelect option (1-3): ");
69
63
  rl.close();
70
64
  const targetDir = path.join(process.cwd(), projectName);
71
65
  if (fs.existsSync(targetDir)) {
72
- console.error(`
73
- \u274C Error: Directory "${projectName}" already exists.`);
66
+ console.error("\u274C Directory already exists");
74
67
  process.exit(1);
75
68
  }
76
69
  try {
@@ -80,24 +73,32 @@ async function main() {
80
73
  await scaffoldVite(projectName, targetDir);
81
74
  } else {
82
75
  console.log("Canceled.");
83
- process.exit(0);
84
76
  }
85
- } catch (error) {
86
- console.error("\n\u274C Scaffolding failed:", error);
87
- process.exit(1);
77
+ } catch (e) {
78
+ console.error("\u274C Error:", e);
88
79
  }
89
- process.exit(0);
90
80
  }
91
81
  async function scaffoldNextjs(projectName2, targetDir) {
92
- console.log("\n\u{1F4E6} Creating Next.js application...");
93
- execSync(`npx create-next-app@latest ${projectName2} --ts --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm`, { stdio: "inherit" });
82
+ console.log("\n\u{1F4E6} Creating Next.js app...");
83
+ execSync(
84
+ `npx create-next-app@latest ${projectName2} --ts --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm`,
85
+ { stdio: "inherit" }
86
+ );
94
87
  console.log("\n\u{1F4E6} Installing dependencies...");
95
- execSync("npm install @unciatech/file-manager tailwindcss-animate", { cwd: targetDir, stdio: "inherit" });
96
- const componentsDir = path.join(targetDir, "src", "components");
97
- if (!fs.existsSync(componentsDir)) fs.mkdirSync(componentsDir, { recursive: true });
98
- fs.writeFileSync(path.join(componentsDir, "FileManagerDemo.tsx"), TEMPLATE, "utf-8");
99
- const pagePath = path.join(targetDir, "src", "app", "page.tsx");
100
- fs.writeFileSync(pagePath, `import FileManagerDemo from "@/components/FileManagerDemo";
88
+ execSync("npm install @unciatech/file-manager tailwindcss-animate", {
89
+ cwd: targetDir,
90
+ stdio: "inherit"
91
+ });
92
+ const componentsDir = path.join(targetDir, "src/components");
93
+ fs.mkdirSync(componentsDir, { recursive: true });
94
+ fs.writeFileSync(
95
+ path.join(componentsDir, "FileManagerDemo.tsx"),
96
+ TEMPLATE
97
+ );
98
+ const pagePath = path.join(targetDir, "src/app/page.tsx");
99
+ fs.writeFileSync(
100
+ pagePath,
101
+ `import FileManagerDemo from "@/components/FileManagerDemo";
101
102
 
102
103
  export default function Home() {
103
104
  return (
@@ -106,64 +107,51 @@ export default function Home() {
106
107
  </main>
107
108
  );
108
109
  }
109
- `);
110
+ `
111
+ );
110
112
  printSuccess(projectName2);
111
113
  }
112
114
  async function scaffoldVite(projectName2, targetDir) {
113
- console.log("\n\u{1F4E6} Creating Vite React application...");
114
- execSync(`npm create vite@latest ${projectName2} -- --template react-ts`, { stdio: "inherit" });
115
+ console.log("\n\u{1F4E6} Creating Vite app...");
116
+ execSync(
117
+ `npm create vite@latest ${projectName2} -- --template react-ts`,
118
+ { stdio: "inherit" }
119
+ );
115
120
  console.log("\n\u{1F4E6} Installing dependencies...");
116
121
  execSync("npm install", { cwd: targetDir, stdio: "inherit" });
117
122
  execSync(
118
- "npm install tailwindcss @tailwindcss/vite @unciatech/file-manager tw-animate-css",
123
+ "npm install tailwindcss @tailwindcss/vite tw-animate-css @unciatech/file-manager",
119
124
  { cwd: targetDir, stdio: "inherit" }
120
125
  );
121
- const viteConfigPath = path.join(targetDir, "vite.config.ts");
122
- fs.writeFileSync(
123
- viteConfigPath,
124
- `import { defineConfig } from 'vite'
126
+ const viteConfig = `import { defineConfig } from 'vite'
125
127
  import react from '@vitejs/plugin-react'
126
128
  import tailwindcss from '@tailwindcss/vite'
127
129
 
128
130
  export default defineConfig({
129
- plugins: [
130
- react(),
131
- tailwindcss(),
132
- ],
131
+ plugins: [react(), tailwindcss()],
133
132
  })
134
- `
135
- );
136
- const cssPath = path.join(targetDir, "src", "index.css");
137
- fs.writeFileSync(
138
- cssPath,
139
- `@import "tailwindcss";
133
+ `;
134
+ fs.writeFileSync(path.join(targetDir, "vite.config.ts"), viteConfig);
135
+ const css = `@import "tailwindcss";
140
136
  @import "tw-animate-css";
141
137
 
142
138
  @source "../node_modules/@unciatech/file-manager/dist/**/*.{js,ts,jsx,tsx}";
143
- `
144
- );
145
- const mainPath = path.join(targetDir, "src", "main.tsx");
146
- if (fs.existsSync(mainPath)) {
147
- let mainContent = fs.readFileSync(mainPath, "utf8");
148
- if (!mainContent.includes("@unciatech/file-manager/styles")) {
149
- mainContent = `import "@unciatech/file-manager/styles";
150
- ` + mainContent;
151
- fs.writeFileSync(mainPath, mainContent);
152
- }
153
- }
154
- const componentsDir = path.join(targetDir, "src", "components");
155
- if (!fs.existsSync(componentsDir)) {
156
- fs.mkdirSync(componentsDir, { recursive: true });
139
+ `;
140
+ fs.writeFileSync(path.join(targetDir, "src/index.css"), css);
141
+ const mainFile = path.join(targetDir, "src/main.tsx");
142
+ let main2 = fs.readFileSync(mainFile, "utf8");
143
+ if (!main2.includes("@unciatech/file-manager/styles")) {
144
+ main2 = `import "@unciatech/file-manager/styles";
145
+ ` + main2;
157
146
  }
147
+ fs.writeFileSync(mainFile, main2);
148
+ const compDir = path.join(targetDir, "src/components");
149
+ fs.mkdirSync(compDir, { recursive: true });
158
150
  fs.writeFileSync(
159
- path.join(componentsDir, "FileManagerDemo.tsx"),
160
- TEMPLATE,
161
- "utf-8"
151
+ path.join(compDir, "FileManagerDemo.tsx"),
152
+ TEMPLATE
162
153
  );
163
- const appPath = path.join(targetDir, "src", "App.tsx");
164
- fs.writeFileSync(
165
- appPath,
166
- `import FileManagerDemo from "./components/FileManagerDemo";
154
+ const app = `import FileManagerDemo from "./components/FileManagerDemo";
167
155
 
168
156
  function App() {
169
157
  return (
@@ -174,17 +162,18 @@ function App() {
174
162
  }
175
163
 
176
164
  export default App;
177
- `
178
- );
165
+ `;
166
+ fs.writeFileSync(path.join(targetDir, "src/App.tsx"), app);
179
167
  printSuccess(projectName2);
180
168
  }
181
- function printSuccess(projectName2, devCmd = "npm run dev") {
182
- console.log("\n=========================================");
183
- console.log("\u{1F389} Your Media Library application is ready!");
184
- console.log("=========================================");
185
- console.log("\nNext steps:");
186
- console.log(` cd ${projectName2}`);
187
- console.log(` ${devCmd}`);
188
- console.log("\nEnjoy building! \u{1F5C2}\uFE0F\n");
169
+ function printSuccess(projectName2) {
170
+ console.log("\n=================================");
171
+ console.log("\u{1F389} Project ready!");
172
+ console.log("=================================");
173
+ console.log(`
174
+ Next steps:`);
175
+ console.log(`cd ${projectName2}`);
176
+ console.log(`npm run dev
177
+ `);
189
178
  }
190
179
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unciatech/file-manager",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "description": "Modern file manager component for React and Next.js",
5
5
  "author": "Avi",
6
6
  "license": "MIT",