@unciatech/file-manager 0.0.3 → 0.0.4
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/dist/cli.js +20 -23
- package/dist/cli.mjs +19 -22
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var y=Object.create;var d=Object.defineProperty;var
|
|
2
|
+
"use strict";var y=Object.create;var d=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var F=(n,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of v(e))!S.call(n,t)&&t!==o&&d(n,t,{get:()=>e[t],enumerable:!(c=x(e,t))||c.enumerable});return n};var p=(n,e,o)=>(o=n!=null?y(h(n)):{},F(e||!n||!n.__esModule?d(o,"default",{value:n,enumerable:!0}):o,n));var i=p(require("fs")),s=p(require("path")),a=require("child_process"),g=p(require("readline")),u=process.argv.slice(2),j=u[0],l=u[1],M=g.default.createInterface({input:process.stdin,output:process.stdout}),C=n=>new Promise(e=>M.question(n,e)),m=`"use client";
|
|
3
3
|
|
|
4
|
-
import React from "react";
|
|
5
|
-
import {
|
|
6
|
-
import { FileManager } from "@unciatech/file-manager";
|
|
7
|
-
import { MockProvider } from "@unciatech/file-manager";
|
|
4
|
+
import React, { Suspense } from "react";
|
|
5
|
+
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
8
6
|
|
|
9
7
|
export default function FileManagerDemo() {
|
|
10
8
|
const mockProvider = new MockProvider();
|
|
11
9
|
|
|
12
10
|
return (
|
|
13
11
|
<div className="h-screen w-full">
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</FileManagerProvider>
|
|
12
|
+
<Suspense fallback={<div className="p-4">Loading Media Library...</div>}>
|
|
13
|
+
<FileManager
|
|
14
|
+
allowedFileTypes={["audios", "videos", "images", "files"]}
|
|
15
|
+
viewMode="grid"
|
|
16
|
+
provider={mockProvider}
|
|
17
|
+
/>
|
|
18
|
+
</Suspense>
|
|
22
19
|
</div>
|
|
23
20
|
);
|
|
24
21
|
}
|
|
25
|
-
`;async function
|
|
22
|
+
`;async function P(){if(j!=="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(s.default.join(process.cwd(),"components"))?o=s.default.join(process.cwd(),"components"):i.default.existsSync(s.default.join(process.cwd(),"src","components"))&&(o=s.default.join(process.cwd(),"src","components"));let c=s.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
23
|
\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
|
|
28
|
-
Select an option (1-3): `),e=
|
|
24
|
+
`),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 C(`
|
|
25
|
+
Select an option (1-3): `),e=s.default.join(process.cwd(),l);try{n==="1"?await k(l,e):n==="2"?await b(l,e):(console.log("Canceled."),process.exit(0))}catch(o){console.error(`
|
|
29
26
|
\u274C Scaffolding failed:`,o),process.exit(1)}process.exit(0)}async function k(n,e){console.log(`
|
|
30
27
|
\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=
|
|
28
|
+
\u{1F4E6} Installing dependencies (@unciatech/file-manager, tailwindcss-animate)...`),(0,a.execSync)("npm install @unciatech/file-manager tailwindcss-animate",{cwd:e,stdio:"inherit"});let o=s.default.join(e,"src","components");i.default.existsSync(o)||i.default.mkdirSync(o,{recursive:!0}),i.default.writeFileSync(s.default.join(o,"FileManagerDemo.tsx"),m,"utf-8");let c=s.default.join(e,"src","app","page.tsx");i.default.writeFileSync(c,`import FileManagerDemo from "@/components/FileManagerDemo";
|
|
32
29
|
|
|
33
30
|
export default function Home() {
|
|
34
31
|
return (
|
|
@@ -37,13 +34,13 @@ export default function Home() {
|
|
|
37
34
|
</main>
|
|
38
35
|
);
|
|
39
36
|
}
|
|
40
|
-
`);let s
|
|
37
|
+
`);let t=s.default.join(e,"src","app","globals.css");if(i.default.existsSync(t)){let r=i.default.readFileSync(t,"utf8");r.includes("@source")||(r=`@import "tailwindcss";
|
|
41
38
|
@plugin "tailwindcss-animate";
|
|
42
39
|
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
43
40
|
|
|
44
|
-
`+r.replace('@import "tailwindcss";',""),i.default.writeFileSync(
|
|
41
|
+
`+r.replace('@import "tailwindcss";',""),i.default.writeFileSync(t,r))}f(n)}async function b(n,e){console.log(`
|
|
45
42
|
\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=
|
|
43
|
+
\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=s.default.join(e,"vite.config.ts");i.default.writeFileSync(o,`import { defineConfig } from 'vite'
|
|
47
44
|
import react from '@vitejs/plugin-react'
|
|
48
45
|
import tailwindcss from '@tailwindcss/vite'
|
|
49
46
|
|
|
@@ -53,9 +50,9 @@ export default defineConfig({
|
|
|
53
50
|
tailwindcss(),
|
|
54
51
|
],
|
|
55
52
|
})
|
|
56
|
-
`);let s
|
|
53
|
+
`);let t=s.default.join(e,"src","index.css");i.default.writeFileSync(t,`@import "tailwindcss";
|
|
57
54
|
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
58
|
-
`);let r=
|
|
55
|
+
`);let r=s.default.join(e,"src","components");i.default.existsSync(r)||i.default.mkdirSync(r,{recursive:!0}),i.default.writeFileSync(s.default.join(r,"FileManagerDemo.tsx"),m,"utf-8");let w=s.default.join(e,"src","App.tsx");i.default.writeFileSync(w,`import FileManagerDemo from "./components/FileManagerDemo";
|
|
59
56
|
|
|
60
57
|
function App() {
|
|
61
58
|
return (
|
|
@@ -66,4 +63,4 @@ function App() {
|
|
|
66
63
|
}
|
|
67
64
|
|
|
68
65
|
export default App;
|
|
69
|
-
`),
|
|
66
|
+
`),f(n,"npm run dev")}function f(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")}P();
|
package/dist/cli.mjs
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import n from"fs";import i from"path";import{execSync as l}from"child_process";import
|
|
2
|
+
import n from"fs";import i from"path";import{execSync as l}from"child_process";import u from"readline";var m=process.argv.slice(2),f=m[0],a=m[1],w=u.createInterface({input:process.stdin,output:process.stdout}),y=o=>new Promise(e=>w.question(o,e)),p=`"use client";
|
|
3
3
|
|
|
4
|
-
import React from "react";
|
|
5
|
-
import {
|
|
6
|
-
import { FileManager } from "@unciatech/file-manager";
|
|
7
|
-
import { MockProvider } from "@unciatech/file-manager";
|
|
4
|
+
import React, { Suspense } from "react";
|
|
5
|
+
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
8
6
|
|
|
9
7
|
export default function FileManagerDemo() {
|
|
10
8
|
const mockProvider = new MockProvider();
|
|
11
9
|
|
|
12
10
|
return (
|
|
13
11
|
<div className="h-screen w-full">
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</FileManagerProvider>
|
|
12
|
+
<Suspense fallback={<div className="p-4">Loading Media Library...</div>}>
|
|
13
|
+
<FileManager
|
|
14
|
+
allowedFileTypes={["audios", "videos", "images", "files"]}
|
|
15
|
+
viewMode="grid"
|
|
16
|
+
provider={mockProvider}
|
|
17
|
+
/>
|
|
18
|
+
</Suspense>
|
|
22
19
|
</div>
|
|
23
20
|
);
|
|
24
21
|
}
|
|
25
|
-
`;async function
|
|
22
|
+
`;async function x(){if(f!=="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 s=process.cwd();n.existsSync(i.join(process.cwd(),"components"))?s=i.join(process.cwd(),"components"):n.existsSync(i.join(process.cwd(),"src","components"))&&(s=i.join(process.cwd(),"src","components"));let c=i.join(s,"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
23
|
\u{1F680} Initializing a new application: ${a}
|
|
27
24
|
`),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
|
|
29
|
-
\u274C Scaffolding failed:`,
|
|
25
|
+
Select an option (1-3): `),e=i.join(process.cwd(),a);try{o==="1"?await v(a,e):o==="2"?await h(a,e):(console.log("Canceled."),process.exit(0))}catch(s){console.error(`
|
|
26
|
+
\u274C Scaffolding failed:`,s),process.exit(1)}process.exit(0)}async function v(o,e){console.log(`
|
|
30
27
|
\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
|
|
28
|
+
\u{1F4E6} Installing dependencies (@unciatech/file-manager, tailwindcss-animate)...`),l("npm install @unciatech/file-manager tailwindcss-animate",{cwd:e,stdio:"inherit"});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 c=i.join(e,"src","app","page.tsx");n.writeFileSync(c,`import FileManagerDemo from "@/components/FileManagerDemo";
|
|
32
29
|
|
|
33
30
|
export default function Home() {
|
|
34
31
|
return (
|
|
@@ -37,13 +34,13 @@ export default function Home() {
|
|
|
37
34
|
</main>
|
|
38
35
|
);
|
|
39
36
|
}
|
|
40
|
-
`);let r=i.join(e,"src","app","globals.css");if(n.existsSync(r)){let
|
|
37
|
+
`);let r=i.join(e,"src","app","globals.css");if(n.existsSync(r)){let t=n.readFileSync(r,"utf8");t.includes("@source")||(t=`@import "tailwindcss";
|
|
41
38
|
@plugin "tailwindcss-animate";
|
|
42
39
|
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
43
40
|
|
|
44
|
-
`+
|
|
41
|
+
`+t.replace('@import "tailwindcss";',""),n.writeFileSync(r,t))}d(o)}async function h(o,e){console.log(`
|
|
45
42
|
\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
|
|
43
|
+
\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 s=i.join(e,"vite.config.ts");n.writeFileSync(s,`import { defineConfig } from 'vite'
|
|
47
44
|
import react from '@vitejs/plugin-react'
|
|
48
45
|
import tailwindcss from '@tailwindcss/vite'
|
|
49
46
|
|
|
@@ -55,7 +52,7 @@ export default defineConfig({
|
|
|
55
52
|
})
|
|
56
53
|
`);let r=i.join(e,"src","index.css");n.writeFileSync(r,`@import "tailwindcss";
|
|
57
54
|
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
58
|
-
`);let
|
|
55
|
+
`);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 g=i.join(e,"src","App.tsx");n.writeFileSync(g,`import FileManagerDemo from "./components/FileManagerDemo";
|
|
59
56
|
|
|
60
57
|
function App() {
|
|
61
58
|
return (
|
|
@@ -66,4 +63,4 @@ function App() {
|
|
|
66
63
|
}
|
|
67
64
|
|
|
68
65
|
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")}
|
|
66
|
+
`),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")}x();
|