@unciatech/file-manager 0.0.2 → 0.0.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 +13 -2
- package/dist/cli.js +46 -3
- package/dist/cli.mjs +46 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,9 @@ It supports deep folder nesting, drag-and-drop file uploads, metadata management
|
|
|
19
19
|
- **Icons**: Lucide React
|
|
20
20
|
- **Notifications**: Sonner
|
|
21
21
|
|
|
22
|
+
> [!WARNING]
|
|
23
|
+
> This library is currently in **BETA**. Please report any bugs or feature requests on the GitHub issues page.
|
|
24
|
+
|
|
22
25
|
## 🚀 How to Install and Use in Your Project
|
|
23
26
|
|
|
24
27
|
If you want to integrate this File Manager into your own Next.js or React application, follow this step-by-step guide.
|
|
@@ -30,12 +33,20 @@ Install the library via NPM:
|
|
|
30
33
|
npm install @unciatech/file-manager
|
|
31
34
|
```
|
|
32
35
|
|
|
33
|
-
**(Optional) Quick Start Scaffolding**
|
|
34
|
-
Instead of setting everything up manually,
|
|
36
|
+
**(Optional) ⚡ Magic Quick Start Scaffolding**
|
|
37
|
+
Instead of setting everything up manually, our incredibly powerful init script can generate files for you!
|
|
38
|
+
|
|
39
|
+
**A) If you just want the component inside your CURRENT project:**
|
|
35
40
|
```bash
|
|
36
41
|
npx @unciatech/file-manager init
|
|
37
42
|
```
|
|
38
43
|
|
|
44
|
+
**B) If you want to spawn a brand new full-stack application instantly:**
|
|
45
|
+
```bash
|
|
46
|
+
npx @unciatech/file-manager init my-media-app
|
|
47
|
+
```
|
|
48
|
+
*It will ask if you want Next.js or Vite (React), install Tailwind, install the package, and set everything up for you!*
|
|
49
|
+
|
|
39
50
|
**(CRITICAL) Configure Tailwind CSS:**
|
|
40
51
|
Because this library uses Tailwind CSS, you MUST tell your Tailwind compiler to scan the library components for utility classes, otherwise it will render with zero styles!
|
|
41
52
|
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var y=Object.create;var d=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var S=(n,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of x(e))!F.call(n,s)&&s!==o&&d(n,s,{get:()=>e[s],enumerable:!(c=h(e,s))||c.enumerable});return n};var p=(n,e,o)=>(o=n!=null?y(v(n)):{},S(e||!n||!n.__esModule?d(o,"default",{value:n,enumerable:!0}):o,n));var i=p(require("fs")),t=p(require("path")),a=require("child_process"),g=p(require("readline")),f=process.argv.slice(2),M=f[0],l=f[1],j=g.default.createInterface({input:process.stdin,output:process.stdout}),P=n=>new Promise(e=>j.question(n,e)),m=`"use client";
|
|
3
3
|
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { FileManagerProvider } from "@unciatech/file-manager";
|
|
@@ -7,7 +7,6 @@ import { FileManager } from "@unciatech/file-manager";
|
|
|
7
7
|
import { MockProvider } from "@unciatech/file-manager";
|
|
8
8
|
|
|
9
9
|
export default function FileManagerDemo() {
|
|
10
|
-
// Instantiate the mock provider for demonstration purposes
|
|
11
10
|
const mockProvider = new MockProvider();
|
|
12
11
|
|
|
13
12
|
return (
|
|
@@ -23,4 +22,48 @@ export default function FileManagerDemo() {
|
|
|
23
22
|
</div>
|
|
24
23
|
);
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
`;async function C(){if(M!=="init"&&(console.log("Usage: npx @unciatech/file-manager init [project-name]"),process.exit(0)),!l){console.log("\u{1F680} Generating <FileManagerDemo /> component in the current project...");let o=process.cwd();i.default.existsSync(t.default.join(process.cwd(),"components"))?o=t.default.join(process.cwd(),"components"):i.default.existsSync(t.default.join(process.cwd(),"src","components"))&&(o=t.default.join(process.cwd(),"src","components"));let c=t.default.join(o,"FileManagerDemo.tsx");i.default.existsSync(c)&&(console.error(`\u274C Error: ${c} already exists.`),process.exit(1)),i.default.writeFileSync(c,m,"utf-8"),console.log(`\u2705 Success! Created ${c}`),console.log(""),console.log("You can now import and render <FileManagerDemo /> anywhere in your application."),console.log("Don't forget to configure your Tailwind CSS content to scan the library for styles!"),process.exit(0)}console.log(`
|
|
26
|
+
\u{1F680} Initializing a new application: ${l}
|
|
27
|
+
`),console.log("Which framework would you like to use?"),console.log(" 1) Next.js (App Router, Tailwind v4)"),console.log(" 2) Vite (React, Tailwind v4)"),console.log(" 3) Cancel");let n=await P(`
|
|
28
|
+
Select an option (1-3): `),e=t.default.join(process.cwd(),l);try{n==="1"?await k(l,e):n==="2"?await D(l,e):(console.log("Canceled."),process.exit(0))}catch(o){console.error(`
|
|
29
|
+
\u274C Scaffolding failed:`,o),process.exit(1)}process.exit(0)}async function k(n,e){console.log(`
|
|
30
|
+
\u{1F4E6} Creating Next.js application (this may take a minute)...`),(0,a.execSync)(`npx create-next-app@latest ${n} --ts --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm`,{stdio:"inherit"}),console.log(`
|
|
31
|
+
\u{1F4E6} Installing @unciatech/file-manager...`),(0,a.execSync)("npm install @unciatech/file-manager",{cwd:e,stdio:"inherit"});let o=t.default.join(e,"src","components");i.default.existsSync(o)||i.default.mkdirSync(o,{recursive:!0}),i.default.writeFileSync(t.default.join(o,"FileManagerDemo.tsx"),m,"utf-8");let c=t.default.join(e,"src","app","page.tsx");i.default.writeFileSync(c,`import FileManagerDemo from "@/components/FileManagerDemo";
|
|
32
|
+
|
|
33
|
+
export default function Home() {
|
|
34
|
+
return (
|
|
35
|
+
<main className="min-h-screen bg-neutral-50">
|
|
36
|
+
<FileManagerDemo />
|
|
37
|
+
</main>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
`);let s=t.default.join(e,"src","app","globals.css");if(i.default.existsSync(s)){let r=i.default.readFileSync(s,"utf8");r.includes("@source")||(r=`@import "tailwindcss";
|
|
41
|
+
@plugin "tailwindcss-animate";
|
|
42
|
+
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
43
|
+
|
|
44
|
+
`+r.replace('@import "tailwindcss";',""),i.default.writeFileSync(s,r))}u(n)}async function D(n,e){console.log(`
|
|
45
|
+
\u{1F4E6} Creating Vite React application...`),(0,a.execSync)(`npm create vite@latest ${n} -- --template react-ts`,{stdio:"inherit"}),console.log(`
|
|
46
|
+
\u{1F4E6} Installing dependencies (Tailwind + File Manager)...`),(0,a.execSync)("npm install",{cwd:e,stdio:"inherit"}),(0,a.execSync)("npm install tailwindcss @tailwindcss/vite @unciatech/file-manager",{cwd:e,stdio:"inherit"});let o=t.default.join(e,"vite.config.ts");i.default.writeFileSync(o,`import { defineConfig } from 'vite'
|
|
47
|
+
import react from '@vitejs/plugin-react'
|
|
48
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
49
|
+
|
|
50
|
+
export default defineConfig({
|
|
51
|
+
plugins: [
|
|
52
|
+
react(),
|
|
53
|
+
tailwindcss(),
|
|
54
|
+
],
|
|
55
|
+
})
|
|
56
|
+
`);let s=t.default.join(e,"src","index.css");i.default.writeFileSync(s,`@import "tailwindcss";
|
|
57
|
+
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
58
|
+
`);let r=t.default.join(e,"src","components");i.default.existsSync(r)||i.default.mkdirSync(r,{recursive:!0}),i.default.writeFileSync(t.default.join(r,"FileManagerDemo.tsx"),m,"utf-8");let w=t.default.join(e,"src","App.tsx");i.default.writeFileSync(w,`import FileManagerDemo from "./components/FileManagerDemo";
|
|
59
|
+
|
|
60
|
+
function App() {
|
|
61
|
+
return (
|
|
62
|
+
<div className="min-h-screen bg-neutral-50">
|
|
63
|
+
<FileManagerDemo />
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default App;
|
|
69
|
+
`),u(n,"npm run dev")}function u(n,e="npm run dev"){console.log("\\n========================================="),console.log("\u{1F389} Your Media Library application is ready!"),console.log("========================================="),console.log("\\nNext steps:"),console.log(` cd ${n}`),console.log(` ${e}`),console.log("\\nEnjoy building! \u{1F5C2}\uFE0F\\n")}C();
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import n from"fs";import i from"path";import{execSync as l}from"child_process";import f from"readline";var m=process.argv.slice(2),u=m[0],a=m[1],w=f.createInterface({input:process.stdin,output:process.stdout}),y=o=>new Promise(e=>w.question(o,e)),p=`"use client";
|
|
3
3
|
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { FileManagerProvider } from "@unciatech/file-manager";
|
|
@@ -7,7 +7,6 @@ import { FileManager } from "@unciatech/file-manager";
|
|
|
7
7
|
import { MockProvider } from "@unciatech/file-manager";
|
|
8
8
|
|
|
9
9
|
export default function FileManagerDemo() {
|
|
10
|
-
// Instantiate the mock provider for demonstration purposes
|
|
11
10
|
const mockProvider = new MockProvider();
|
|
12
11
|
|
|
13
12
|
return (
|
|
@@ -23,4 +22,48 @@ export default function FileManagerDemo() {
|
|
|
23
22
|
</div>
|
|
24
23
|
);
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
`;async function h(){if(u!=="init"&&(console.log("Usage: npx @unciatech/file-manager init [project-name]"),process.exit(0)),!a){console.log("\u{1F680} Generating <FileManagerDemo /> component in the current project...");let t=process.cwd();n.existsSync(i.join(process.cwd(),"components"))?t=i.join(process.cwd(),"components"):n.existsSync(i.join(process.cwd(),"src","components"))&&(t=i.join(process.cwd(),"src","components"));let c=i.join(t,"FileManagerDemo.tsx");n.existsSync(c)&&(console.error(`\u274C Error: ${c} already exists.`),process.exit(1)),n.writeFileSync(c,p,"utf-8"),console.log(`\u2705 Success! Created ${c}`),console.log(""),console.log("You can now import and render <FileManagerDemo /> anywhere in your application."),console.log("Don't forget to configure your Tailwind CSS content to scan the library for styles!"),process.exit(0)}console.log(`
|
|
26
|
+
\u{1F680} Initializing a new application: ${a}
|
|
27
|
+
`),console.log("Which framework would you like to use?"),console.log(" 1) Next.js (App Router, Tailwind v4)"),console.log(" 2) Vite (React, Tailwind v4)"),console.log(" 3) Cancel");let o=await y(`
|
|
28
|
+
Select an option (1-3): `),e=i.join(process.cwd(),a);try{o==="1"?await x(a,e):o==="2"?await v(a,e):(console.log("Canceled."),process.exit(0))}catch(t){console.error(`
|
|
29
|
+
\u274C Scaffolding failed:`,t),process.exit(1)}process.exit(0)}async function x(o,e){console.log(`
|
|
30
|
+
\u{1F4E6} Creating Next.js application (this may take a minute)...`),l(`npx create-next-app@latest ${o} --ts --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm`,{stdio:"inherit"}),console.log(`
|
|
31
|
+
\u{1F4E6} Installing @unciatech/file-manager...`),l("npm install @unciatech/file-manager",{cwd:e,stdio:"inherit"});let t=i.join(e,"src","components");n.existsSync(t)||n.mkdirSync(t,{recursive:!0}),n.writeFileSync(i.join(t,"FileManagerDemo.tsx"),p,"utf-8");let c=i.join(e,"src","app","page.tsx");n.writeFileSync(c,`import FileManagerDemo from "@/components/FileManagerDemo";
|
|
32
|
+
|
|
33
|
+
export default function Home() {
|
|
34
|
+
return (
|
|
35
|
+
<main className="min-h-screen bg-neutral-50">
|
|
36
|
+
<FileManagerDemo />
|
|
37
|
+
</main>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
`);let r=i.join(e,"src","app","globals.css");if(n.existsSync(r)){let s=n.readFileSync(r,"utf8");s.includes("@source")||(s=`@import "tailwindcss";
|
|
41
|
+
@plugin "tailwindcss-animate";
|
|
42
|
+
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
43
|
+
|
|
44
|
+
`+s.replace('@import "tailwindcss";',""),n.writeFileSync(r,s))}d(o)}async function v(o,e){console.log(`
|
|
45
|
+
\u{1F4E6} Creating Vite React application...`),l(`npm create vite@latest ${o} -- --template react-ts`,{stdio:"inherit"}),console.log(`
|
|
46
|
+
\u{1F4E6} Installing dependencies (Tailwind + File Manager)...`),l("npm install",{cwd:e,stdio:"inherit"}),l("npm install tailwindcss @tailwindcss/vite @unciatech/file-manager",{cwd:e,stdio:"inherit"});let t=i.join(e,"vite.config.ts");n.writeFileSync(t,`import { defineConfig } from 'vite'
|
|
47
|
+
import react from '@vitejs/plugin-react'
|
|
48
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
49
|
+
|
|
50
|
+
export default defineConfig({
|
|
51
|
+
plugins: [
|
|
52
|
+
react(),
|
|
53
|
+
tailwindcss(),
|
|
54
|
+
],
|
|
55
|
+
})
|
|
56
|
+
`);let r=i.join(e,"src","index.css");n.writeFileSync(r,`@import "tailwindcss";
|
|
57
|
+
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
58
|
+
`);let s=i.join(e,"src","components");n.existsSync(s)||n.mkdirSync(s,{recursive:!0}),n.writeFileSync(i.join(s,"FileManagerDemo.tsx"),p,"utf-8");let g=i.join(e,"src","App.tsx");n.writeFileSync(g,`import FileManagerDemo from "./components/FileManagerDemo";
|
|
59
|
+
|
|
60
|
+
function App() {
|
|
61
|
+
return (
|
|
62
|
+
<div className="min-h-screen bg-neutral-50">
|
|
63
|
+
<FileManagerDemo />
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default App;
|
|
69
|
+
`),d(o,"npm run dev")}function d(o,e="npm run dev"){console.log("\\n========================================="),console.log("\u{1F389} Your Media Library application is ready!"),console.log("========================================="),console.log("\\nNext steps:"),console.log(` cd ${o}`),console.log(` ${e}`),console.log("\\nEnjoy building! \u{1F5C2}\uFE0F\\n")}h();
|