@unciatech/file-manager 0.0.10 → 0.0.14
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 +29 -14
- package/dist/cli.mjs +29 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var h=Object.create;var g=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var M=(i,e,s,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of F(e))!j.call(i,c)&&c!==s&&g(i,c,{get:()=>e[c],enumerable:!(t=S(e,c))||t.enumerable});return i};var d=(i,e,s)=>(s=i!=null?h(v(i)):{},M(e||!i||!i.__esModule?g(s,"default",{value:i,enumerable:!0}):s,i));var n=d(require("fs")),o=d(require("path")),p=require("child_process"),f=d(require("readline")),y=process.argv.slice(2),P=y[0],l=y[1],w=f.default.createInterface({input:process.stdin,output:process.stdout}),C=i=>new Promise(e=>w.question(i,e)),u=`"use client";
|
|
3
3
|
|
|
4
4
|
import React, { Suspense } from "react";
|
|
5
5
|
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
@@ -19,13 +19,14 @@ export default function FileManagerDemo() {
|
|
|
19
19
|
</div>
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
|
-
`;async function
|
|
22
|
+
`;async function k(){if(P!=="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 s=process.cwd();n.default.existsSync(o.default.join(process.cwd(),"components"))?s=o.default.join(process.cwd(),"components"):n.default.existsSync(o.default.join(process.cwd(),"src","components"))&&(s=o.default.join(process.cwd(),"src","components"));let t=o.default.join(s,"FileManagerDemo.tsx");n.default.existsSync(t)&&(console.error(`\u274C Error: ${t} already exists.`),process.exit(1)),n.default.writeFileSync(t,u,"utf-8"),console.log(`\u2705 Success! Created ${t}`),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(`
|
|
23
23
|
\u{1F680} Initializing a new application: ${l}
|
|
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
|
|
25
|
-
Select an option (1-3): `),e=
|
|
26
|
-
\u274C
|
|
27
|
-
\
|
|
28
|
-
\u{1F4E6}
|
|
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 i=await C(`
|
|
25
|
+
Select an option (1-3): `),e=o.default.join(process.cwd(),l);n.default.existsSync(e)&&(console.error(`
|
|
26
|
+
\u274C Error: Directory "${l}" already exists in ${process.cwd()}.`),console.error(" Please choose a different project name or delete the existing directory first."),w.close(),process.exit(1));try{i==="1"?await D(l,e):i==="2"?await b(l,e):(console.log("Canceled."),process.exit(0))}catch(s){console.error(`
|
|
27
|
+
\u274C Scaffolding failed:`,s),process.exit(1)}process.exit(0)}async function D(i,e){console.log(`
|
|
28
|
+
\u{1F4E6} Creating Next.js application (this may take a minute)...`),(0,p.execSync)(`npx create-next-app@latest ${i} --ts --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm`,{stdio:"inherit"}),console.log(`
|
|
29
|
+
\u{1F4E6} Installing dependencies (@unciatech/file-manager, tailwindcss-animate)...`),(0,p.execSync)("npm install @unciatech/file-manager tailwindcss-animate",{cwd:e,stdio:"inherit"});let s=o.default.join(e,"src","components");n.default.existsSync(s)||n.default.mkdirSync(s,{recursive:!0}),n.default.writeFileSync(o.default.join(s,"FileManagerDemo.tsx"),u,"utf-8");let t=o.default.join(e,"src","app","page.tsx");n.default.writeFileSync(t,`import FileManagerDemo from "@/components/FileManagerDemo";
|
|
29
30
|
|
|
30
31
|
export default function Home() {
|
|
31
32
|
return (
|
|
@@ -34,13 +35,23 @@ export default function Home() {
|
|
|
34
35
|
</main>
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
|
-
`);let
|
|
38
|
+
`);let c=o.default.join(e,"src","app","media","[[...path]]");n.default.mkdirSync(c,{recursive:!0}),n.default.writeFileSync(o.default.join(c,"page.tsx"),`import FileManagerDemo from "@/components/FileManagerDemo";
|
|
39
|
+
|
|
40
|
+
export default function MediaPage() {
|
|
41
|
+
return (
|
|
42
|
+
<main className="min-h-screen bg-neutral-50">
|
|
43
|
+
<FileManagerDemo />
|
|
44
|
+
</main>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
`);let a=o.default.join(e,"src","app","layout.tsx");if(n.default.existsSync(a)){let r=n.default.readFileSync(a,"utf8");r.includes("@unciatech/file-manager/styles")||(r=r.replace(/^(import type)/m,`import '@unciatech/file-manager/styles';
|
|
48
|
+
$1`),n.default.writeFileSync(a,r))}let m=o.default.join(e,"src","app","globals.css");if(n.default.existsSync(m)){let r=n.default.readFileSync(m,"utf8");r.includes("@source")||(r=`@import "tailwindcss";
|
|
38
49
|
@plugin "tailwindcss-animate";
|
|
39
50
|
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
40
51
|
|
|
41
|
-
`+r.replace('@import "tailwindcss";',""),
|
|
42
|
-
\u{1F4E6} Creating Vite React application...`),(0,
|
|
43
|
-
\u{1F4E6} Installing dependencies (Tailwind + File Manager)...`),(0,
|
|
52
|
+
`+r.replace('@import "tailwindcss";',""),n.default.writeFileSync(m,r))}x(i)}async function b(i,e){console.log(`
|
|
53
|
+
\u{1F4E6} Creating Vite React application...`),(0,p.execSync)(`npm create vite@latest ${i} -- --template react-ts`,{stdio:"inherit"}),console.log(`
|
|
54
|
+
\u{1F4E6} Installing dependencies (Tailwind + File Manager)...`),(0,p.execSync)("npm install",{cwd:e,stdio:"inherit"}),(0,p.execSync)("npm install tailwindcss @tailwindcss/vite @unciatech/file-manager",{cwd:e,stdio:"inherit"});let s=o.default.join(e,"vite.config.ts");n.default.writeFileSync(s,`import { defineConfig } from 'vite'
|
|
44
55
|
import react from '@vitejs/plugin-react'
|
|
45
56
|
import tailwindcss from '@tailwindcss/vite'
|
|
46
57
|
|
|
@@ -50,9 +61,9 @@ export default defineConfig({
|
|
|
50
61
|
tailwindcss(),
|
|
51
62
|
],
|
|
52
63
|
})
|
|
53
|
-
`);let
|
|
64
|
+
`);let c=o.default.join(e,"src","index.css");n.default.writeFileSync(c,`@import "tailwindcss";
|
|
54
65
|
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
55
|
-
`);let
|
|
66
|
+
`);let a=o.default.join(e,"src","components");n.default.existsSync(a)||n.default.mkdirSync(a,{recursive:!0}),n.default.writeFileSync(o.default.join(a,"FileManagerDemo.tsx"),u,"utf-8");let m=o.default.join(e,"src","App.tsx");n.default.writeFileSync(m,`import FileManagerDemo from "./components/FileManagerDemo";
|
|
56
67
|
|
|
57
68
|
function App() {
|
|
58
69
|
return (
|
|
@@ -63,4 +74,8 @@ function App() {
|
|
|
63
74
|
}
|
|
64
75
|
|
|
65
76
|
export default App;
|
|
66
|
-
`),
|
|
77
|
+
`),x(i,"npm run dev")}function x(i,e="npm run dev"){console.log(`
|
|
78
|
+
=========================================`),console.log("\u{1F389} Your Media Library application is ready!"),console.log("========================================="),console.log(`
|
|
79
|
+
Next steps:`),console.log(` cd ${i}`),console.log(` ${e}`),console.log(`
|
|
80
|
+
Enjoy building! \u{1F5C2}\uFE0F
|
|
81
|
+
`)}k();
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import e from"fs";import i from"path";import{execSync as p}from"child_process";import y from"readline";var u=process.argv.slice(2),w=u[0],a=u[1],g=y.createInterface({input:process.stdin,output:process.stdout}),x=o=>new Promise(n=>g.question(o,n)),d=`"use client";
|
|
3
3
|
|
|
4
4
|
import React, { Suspense } from "react";
|
|
5
5
|
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
@@ -19,13 +19,14 @@ export default function FileManagerDemo() {
|
|
|
19
19
|
</div>
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
|
-
`;async function
|
|
22
|
+
`;async function h(){if(w!=="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();e.existsSync(i.join(process.cwd(),"components"))?s=i.join(process.cwd(),"components"):e.existsSync(i.join(process.cwd(),"src","components"))&&(s=i.join(process.cwd(),"src","components"));let c=i.join(s,"FileManagerDemo.tsx");e.existsSync(c)&&(console.error(`\u274C Error: ${c} already exists.`),process.exit(1)),e.writeFileSync(c,d,"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(`
|
|
23
23
|
\u{1F680} Initializing a new application: ${a}
|
|
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
|
|
25
|
-
Select an option (1-3): `),
|
|
26
|
-
\u274C
|
|
27
|
-
\
|
|
28
|
-
\u{1F4E6}
|
|
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 x(`
|
|
25
|
+
Select an option (1-3): `),n=i.join(process.cwd(),a);e.existsSync(n)&&(console.error(`
|
|
26
|
+
\u274C Error: Directory "${a}" already exists in ${process.cwd()}.`),console.error(" Please choose a different project name or delete the existing directory first."),g.close(),process.exit(1));try{o==="1"?await S(a,n):o==="2"?await F(a,n):(console.log("Canceled."),process.exit(0))}catch(s){console.error(`
|
|
27
|
+
\u274C Scaffolding failed:`,s),process.exit(1)}process.exit(0)}async function S(o,n){console.log(`
|
|
28
|
+
\u{1F4E6} Creating Next.js application (this may take a minute)...`),p(`npx create-next-app@latest ${o} --ts --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm`,{stdio:"inherit"}),console.log(`
|
|
29
|
+
\u{1F4E6} Installing dependencies (@unciatech/file-manager, tailwindcss-animate)...`),p("npm install @unciatech/file-manager tailwindcss-animate",{cwd:n,stdio:"inherit"});let s=i.join(n,"src","components");e.existsSync(s)||e.mkdirSync(s,{recursive:!0}),e.writeFileSync(i.join(s,"FileManagerDemo.tsx"),d,"utf-8");let c=i.join(n,"src","app","page.tsx");e.writeFileSync(c,`import FileManagerDemo from "@/components/FileManagerDemo";
|
|
29
30
|
|
|
30
31
|
export default function Home() {
|
|
31
32
|
return (
|
|
@@ -34,13 +35,23 @@ export default function Home() {
|
|
|
34
35
|
</main>
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
|
-
`);let
|
|
38
|
+
`);let m=i.join(n,"src","app","media","[[...path]]");e.mkdirSync(m,{recursive:!0}),e.writeFileSync(i.join(m,"page.tsx"),`import FileManagerDemo from "@/components/FileManagerDemo";
|
|
39
|
+
|
|
40
|
+
export default function MediaPage() {
|
|
41
|
+
return (
|
|
42
|
+
<main className="min-h-screen bg-neutral-50">
|
|
43
|
+
<FileManagerDemo />
|
|
44
|
+
</main>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
`);let r=i.join(n,"src","app","layout.tsx");if(e.existsSync(r)){let t=e.readFileSync(r,"utf8");t.includes("@unciatech/file-manager/styles")||(t=t.replace(/^(import type)/m,`import '@unciatech/file-manager/styles';
|
|
48
|
+
$1`),e.writeFileSync(r,t))}let l=i.join(n,"src","app","globals.css");if(e.existsSync(l)){let t=e.readFileSync(l,"utf8");t.includes("@source")||(t=`@import "tailwindcss";
|
|
38
49
|
@plugin "tailwindcss-animate";
|
|
39
50
|
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
40
51
|
|
|
41
|
-
`+t.replace('@import "tailwindcss";',""),
|
|
42
|
-
\u{1F4E6} Creating Vite React application...`),
|
|
43
|
-
\u{1F4E6} Installing dependencies (Tailwind + File Manager)...`),
|
|
52
|
+
`+t.replace('@import "tailwindcss";',""),e.writeFileSync(l,t))}f(o)}async function F(o,n){console.log(`
|
|
53
|
+
\u{1F4E6} Creating Vite React application...`),p(`npm create vite@latest ${o} -- --template react-ts`,{stdio:"inherit"}),console.log(`
|
|
54
|
+
\u{1F4E6} Installing dependencies (Tailwind + File Manager)...`),p("npm install",{cwd:n,stdio:"inherit"}),p("npm install tailwindcss @tailwindcss/vite @unciatech/file-manager",{cwd:n,stdio:"inherit"});let s=i.join(n,"vite.config.ts");e.writeFileSync(s,`import { defineConfig } from 'vite'
|
|
44
55
|
import react from '@vitejs/plugin-react'
|
|
45
56
|
import tailwindcss from '@tailwindcss/vite'
|
|
46
57
|
|
|
@@ -50,9 +61,9 @@ export default defineConfig({
|
|
|
50
61
|
tailwindcss(),
|
|
51
62
|
],
|
|
52
63
|
})
|
|
53
|
-
`);let
|
|
64
|
+
`);let m=i.join(n,"src","index.css");e.writeFileSync(m,`@import "tailwindcss";
|
|
54
65
|
@source "../../node_modules/@unciatech/file-manager/dist";
|
|
55
|
-
`);let
|
|
66
|
+
`);let r=i.join(n,"src","components");e.existsSync(r)||e.mkdirSync(r,{recursive:!0}),e.writeFileSync(i.join(r,"FileManagerDemo.tsx"),d,"utf-8");let l=i.join(n,"src","App.tsx");e.writeFileSync(l,`import FileManagerDemo from "./components/FileManagerDemo";
|
|
56
67
|
|
|
57
68
|
function App() {
|
|
58
69
|
return (
|
|
@@ -63,4 +74,8 @@ function App() {
|
|
|
63
74
|
}
|
|
64
75
|
|
|
65
76
|
export default App;
|
|
66
|
-
`),
|
|
77
|
+
`),f(o,"npm run dev")}function f(o,n="npm run dev"){console.log(`
|
|
78
|
+
=========================================`),console.log("\u{1F389} Your Media Library application is ready!"),console.log("========================================="),console.log(`
|
|
79
|
+
Next steps:`),console.log(` cd ${o}`),console.log(` ${n}`),console.log(`
|
|
80
|
+
Enjoy building! \u{1F5C2}\uFE0F
|
|
81
|
+
`)}h();
|