@das-fed/cli 1.0.0-beta.0
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/bin/index.js +2 -0
- package/package.json +39 -0
- package/src/commands/build/index.js +1 -0
- package/src/commands/create-app/index.js +1 -0
- package/src/commands/dev/index.js +1 -0
- package/src/commands/dev-helper/index.js +1 -0
- package/src/commands/dev-helper/init-das-fe-web-type/index.js +18 -0
- package/src/commands/dev-helper/init-das-icons.js +0 -0
- package/src/commands/dev-helper/init-git-ignore.js +3 -0
- package/src/commands/dev-helper/init-public-config.js +1 -0
- package/src/commands/dev-helper/watchers/i18n/index.js +1 -0
- package/src/commands/dev-helper/watchers/index.js +1 -0
- package/src/commands/dev-helper/watchers/theme/index.js +1 -0
- package/src/commands/help/index.js +1 -0
- package/src/commands/version/index.js +1 -0
- package/src/index.js +1 -0
- package/src/utils/get-cli-config/index.js +1 -0
- package/src/utils/json2snippets/index.js +1 -0
- package/src/utils/json2type/index.js +2 -0
- package/src/utils/minio.js +1 -0
- package/src/utils/ts-morph/index.js +1 -0
- package/src/vite-plugins/das-fe-ui/core/style.js +1 -0
- package/src/vite-plugins/das-fe-ui/index.js +1 -0
- package/src/vite-plugins/das-fe-web/index.js +1 -0
- package/src/vite-plugins/index.js +1 -0
package/bin/index.js
ADDED
package/package.json
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"name": "@das-fed/cli",
|
3
|
+
"version": "1.0.0-beta.0",
|
4
|
+
"description": "",
|
5
|
+
"type": "module",
|
6
|
+
"main": "src/index.js",
|
7
|
+
"bin": {
|
8
|
+
"das-cli": "bin/index.js"
|
9
|
+
},
|
10
|
+
"keywords": [],
|
11
|
+
"author": "",
|
12
|
+
"license": "ISC",
|
13
|
+
"dependencies": {
|
14
|
+
"@dimple-smile/node-helper": "^1.0.0",
|
15
|
+
"chokidar": "^3.6.0",
|
16
|
+
"concurrently": "^8.2.2",
|
17
|
+
"fast-glob": "^3.3.2",
|
18
|
+
"json-schema-to-typescript": "^13.1.2",
|
19
|
+
"json5": "^2.2.3",
|
20
|
+
"minimatch": "^9.0.3",
|
21
|
+
"minimist": "^1.2.8",
|
22
|
+
"ts-morph": "^21.0.1",
|
23
|
+
"vite-plugin-style-import": "^2.0.0"
|
24
|
+
},
|
25
|
+
"devDependencies": {
|
26
|
+
"es-module-lexer": "^1.4.1",
|
27
|
+
"esbuild": "^0.20.1",
|
28
|
+
"fs-extra": "^11.2.0",
|
29
|
+
"svgo": "^3.2.0",
|
30
|
+
"svgstore": "^3.0.1",
|
31
|
+
"uglify-js": "^3.17.4",
|
32
|
+
"unplugin-auto-import": "^0.17.5",
|
33
|
+
"unplugin-vue-components": "^0.26.0"
|
34
|
+
},
|
35
|
+
"publishConfig": {
|
36
|
+
"access": "public",
|
37
|
+
"registry": "https://registry.npmjs.org"
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
import concurrently from"concurrently";import{initPublicConfig}from"../dev-helper/init-public-config.js";import{initWatchers}from"../dev-helper/watchers/index.js";export default{handle:i=>{var e={cwd:process.cwd(),isDev:!1,isBuild:!0};initPublicConfig(e),initWatchers(e),concurrently([{command:"npx vite build",name:"vite"}])}};
|
@@ -0,0 +1 @@
|
|
1
|
+
export default{alias:["create","init","-c"],handle:e=>{console.log("create-web-app")}};
|
@@ -0,0 +1 @@
|
|
1
|
+
import concurrently from"concurrently";import{dirname,resolve}from"path";import{fileURLToPath}from"url";const __filename=fileURLToPath(import.meta.url),__dirname=dirname(__filename);export default{handle:e=>{concurrently([{command:"das-cli dev-helper",name:"das-cli"},{command:"npx vite",name:"vite"}])}};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{initGitignore}from"./init-git-ignore.js";import{initPublicConfig}from"./init-public-config.js";import{initWatchers}from"./watchers/index.js";import fs from"fs-extra";import{resolve}from"path";import{fileURLToPath}from"url";import{dirname}from"path";import{execSync}from"child_process";const __filename=fileURLToPath(import.meta.url),__dirname=dirname(__filename),runPackageScript=async(i,r)=>{var i=resolve(__dirname,"../../../../",i),e=resolve(i,r);await fs.exists(e)&&execSync("node "+r,{cwd:i})};export default{handle:async i=>{console.log("das-cli dev-helper running!");var r={cwd:process.cwd(),isDev:!0};initGitignore(r),initPublicConfig(r),initWatchers(r),runPackageScript("das-ui","scripts/utils/build-svg-icon.js")}};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import fs from"fs-extra";import{resolve}from"path";const initDasFeWebType=async e=>{e=e.cwd||process.cwd(),e=resolve(e,"src/das-fe-local-runtime/das-fe.d.ts");await fs.exists(e)||await fs.ensureFile(e);await fs.writeFile(e,`
|
2
|
+
import type { ThemeName, ThemeVarKey } from './theme/type'
|
3
|
+
import type { I18NName, I18NKey } from './i18n/type'
|
4
|
+
|
5
|
+
export function setTheme(key?: ThemeName): any
|
6
|
+
export function setThemeRule(key?: ThemeVarKey): any
|
7
|
+
export function getThemeRule(key?: ThemeVarKey): any
|
8
|
+
export function currentTheme(): any
|
9
|
+
export function getVar(key?: ThemeVarKey): string
|
10
|
+
export function getVarValue(key?: ThemeVarKey): any
|
11
|
+
|
12
|
+
export function setI18nRule(options?: any): any
|
13
|
+
export function getI18nRule(key?: I18NKey): any
|
14
|
+
export function i18n(key?: I18NKey): any
|
15
|
+
export function t(key?: I18NKey): any
|
16
|
+
export function setLang(key?: I18NName): any
|
17
|
+
export function getLang(): any
|
18
|
+
`)};export{initDasFeWebType};
|
File without changes
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import{resolve}from"path";import fs from"fs-extra";const ignoreList=["*.local.*","*/*local*/*"],initGitignore=async(t={})=>{t=(t||{}).isDev;if(t){t=resolve(process.cwd(),".gitignore");await fs.exists(t)||await fs.writeFile(t,"");let i=(await fs.readFile(t)).toString();for(const e of ignoreList)i.indexOf(e)<0&&(i+=`\r
|
2
|
+
${e}\r
|
3
|
+
`);await fs.writeFile(t,i)}};export{initGitignore};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{resolve}from"path";import fs from"fs-extra";const initPublicConfig=async(i={})=>{var i=i["isDev"],s=resolve(process.cwd(),"public/config.js"),o=resolve(process.cwd(),"public/config.local.js");await fs.exists(s)||await fs.writeFile(s,"window.config = {}"),i&&!await fs.exists(o)&&await fs.copyFile(s,o)};export{initPublicConfig};
|
@@ -0,0 +1 @@
|
|
1
|
+
import glob from"fast-glob";import fs from"fs-extra";import json5 from"json5";import{resolve}from"path";import{getExportDefaultsByAst}from"../../../../utils/ts-morph/index.js";import{json2type}from"../../../../utils/json2type/index.js";import{getCliConfig}from"../../../../utils/get-cli-config/index.js";const watchGlob=["src/views/*/i18n/*.ts"],handle=async(t={})=>{var e=t["cwd"],o=(await getCliConfig()).i18n?.watchGlob||[],o=getExportDefaultsByAst([...watchGlob,...o],t);let s={};o.map((t,e)=>{t=t.defaultText;Object.assign(s,json5.parse(t))});var a=[];for(const c of await glob(["src/**/*.vue"]))for(var r=(await fs.readFile(c)).toString(),i=/i18n\(\s*(.+)\s*\)/g;null!==(l=i.exec(r));){var[,l]=l;a.push(l)}a.forEach(t=>{for(var e=/['"](.*?)['"]/g;null!==(o=e.exec(t));){var[,o]=o;s[o]||(s[o]={})}});const n={"zh-CN":""};Object.values(s).filter(t=>!!t["zh-CN"]).map(t=>Object.assign(n,t)),0===Object.keys(s).length&&(s.any="");t=resolve(e,"src/das-fe-local-runtime/i18n/type.d.ts");await json2type({data:[{title:"I18NName",type:"string",enum:Object.keys(n)},{title:"I18NKey",type:"string",enum:Object.keys(s)}],outputFilePath:t})};export default{name:"das-i18n",glob:watchGlob,ignoreGlob:[],load:handle,change:handle};
|
@@ -0,0 +1 @@
|
|
1
|
+
import glob from"fast-glob";import chokidar from"chokidar";import{minimatch}from"minimatch";import{dirname,resolve}from"path";import{fileURLToPath}from"url";const __filename=fileURLToPath(import.meta.url),__dirname=dirname(__filename),loadWatcherModules=async a=>{var e=await glob("./*/index.js",{cwd:resolve(__dirname)});if(console.log(resolve(__dirname)),0!==e.length)return Promise.all(e.map(a=>import("./"+a).then(a=>a?.default||{})))},initWatchers=async o=>{const i=await loadWatcherModules();var{isBuild:a=!1,isDev:e=!1,cwd:r=process.cwd()}=o||{};i.map(a=>a?.load(o)),e&&!a&&(e=i.map(a=>a.glob||[]).flat().concat(i.map(a=>a.ignoreGlob||[]).flat()),chokidar.watch(e,{persistent:!0,cwd:r}).on("change",e=>{var a=i.find(a=>a.glob.map(a=>minimatch(e,a)).includes(!0));a&&a.change&&(console.log(`${a.name||"das-fe-watcher"} change!`),a.change(o))}))};export{initWatchers};
|
@@ -0,0 +1 @@
|
|
1
|
+
import json5 from"json5";import{resolve}from"path";import{getExportDefaultsByAst}from"../../../../utils/ts-morph/index.js";import{json2type}from"../../../../utils/json2type/index.js";import{json2snippets}from"../../../../utils/json2snippets/index.js";import{getCliConfig}from"../../../../utils/get-cli-config/index.js";const watchGlob=["src/views/*/theme/*.ts"],handle=async(e={})=>{var t=e["cwd"],s=await getCliConfig(),o=s.theme?.watchGlob||[],o=getExportDefaultsByAst([...watchGlob,...o],e);let r={};o.map((e,t)=>{let s=e.defaultText;e=s.match(/getVar\(.*\)/g);if(!e)return Object.assign(r,json5.parse(s));for(const a of e){var o=a.replace("getVar('","").replace("')","");s=s.replace(a,`'var(${o})'`)}Object.assign(r,json5.parse(s))});const a={base:""};Object.values(r).filter(e=>!!e.base).map(e=>Object.assign(a,e)),0===Object.keys(r).length&&(r.any=""),json2type({data:[{title:"ThemeName",type:"string",enum:Object.keys(a)},{title:"ThemeVarKey",type:"string",enum:Object.keys(r)}],outputFilePath:resolve(t,"src/das-fe-local-runtime/theme/type.d.ts")});let l=resolve(t,".vscode/das-theme.local.code-snippets");s.workspaceRoot&&(e=resolve(t,s.workspaceRoot),l=resolve(e,".vscode/das-theme.local.code-snippets")),json2snippets({data:{"das-theme-css变量":{prefix:"dasvar",body:[`var(\${1|${Object.keys(r).join(",")}|})`],scope:"css,scss,less",description:"das-theme-css变量"}},outputFilePath:l})};export default{name:"das-theme",glob:watchGlob,ignoreGlob:[],load:handle,change:handle};
|
@@ -0,0 +1 @@
|
|
1
|
+
export default{alias:["-h","--help"],flags:[],handle:l=>{console.log(l),console.log("help!")}};
|
@@ -0,0 +1 @@
|
|
1
|
+
export default{alias:["-v","-V","--version"],handle:e=>{console.log("this version is xxxx ")}};
|
package/src/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export{dasFeWebVitePlugin}from"./vite-plugins/index.js";
|
@@ -0,0 +1 @@
|
|
1
|
+
import fs from"fs-extra";import{resolve}from"path";import json5 from"json5";const getCliConfig=async(o={})=>{var{cwd:o=process.cwd()}=o||{},o=resolve(o,"das-cli.config.json");return await fs.exists(o)?(o=(await fs.readFile(o)).toString(),json5.parse(o)):{}};export{getCliConfig};
|
@@ -0,0 +1 @@
|
|
1
|
+
import fs from"fs-extra";const json2snippets=async s=>{var{outputFilePath:s="",data:t={}}=s||{};return s&&(await fs.exists(s)&&await fs.remove(s),await fs.ensureFile(s),await fs.writeJSON(s,t,{spaces:2})),t};export{json2snippets};
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import fs from"fs-extra";import jsonSchema2type from"json-schema-to-typescript";const json2type=async(e={})=>{var{outputFilePath:e,data:t={}}=e||{},t=await compile(t);return e&&(await fs.exists(e)&&await fs.remove(e),await fs.ensureFile(e),await fs.writeFile(e,t)),t},compile=async e=>{let t="";if(Array.isArray(e))for(const s of e){var a=await jsonSchema2type.compile(s);t+=a+`\r
|
2
|
+
`}else t=await jsonSchema2type.compile(e);return t};export{json2type};
|
@@ -0,0 +1 @@
|
|
1
|
+
const fs=require("fs-extra"),Minio=require("minio"),path=require("path");let minioClient;const initMinioClient=(e={})=>minioClient=minioClient||new Minio.Client({endPoint:e.host||"192.168.100.26",port:9e3,useSSL:!1,accessKey:"admin",secretKey:"das@123!"}),upload=async(e,i={})=>{if(e){initMinioClient(i);i=path.resolve(__dirname,"../../");e=path.resolve(i,e);const o=fs.createReadStream(e),a=await fs.stat(e);var n=path.extname(e).replace(".","");const s={"Content-Type":"image/"+n};const r="front-end/auto-upload/pc"+e.replace(i,"");return new Promise((n,t)=>{minioClient.putObject("resource",r,o,a.size,s,(e,i)=>{if(e)return console.log("oss资源自动上传失败",r),console.log(e),t(e);n(i)})})}};module.exports={minio:{upload:upload}};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{Project}from"ts-morph";let project;const initProject=(e={})=>project=project||new Project({skipFileDependencyResolution:!0,skipAddingFilesFromTsConfig:!0,skipLoadingLibFiles:!0,compilerOptions:{skipDefaultLibCheck:!0,skipLibCheck:!0,rootDir:e.cwd||process.cwd()},exclude:["node_modules"]}),getExportDefaultsByAst=(e,t={})=>{t=new Project({skipFileDependencyResolution:!0,skipAddingFilesFromTsConfig:!0,skipLoadingLibFiles:!0,compilerOptions:{skipDefaultLibCheck:!0,skipLibCheck:!0,rootDir:t.cwd||process.cwd()},exclude:["node_modules"]});return t.addSourceFilesAtPaths(e),t.getSourceFiles().map(e=>{var t,i,o,r={filePath:e.getFilePath(),name:"default",defaultText:""};for([t,i]of e.getExportedDeclarations())"default"===t&&0!==(o=i.map(e=>(e.getInitializer?e.getInitializer():e).getText())).length&&(r.name=t,r.defaultText=o[0]);return r}).filter(e=>!!e.defaultText)};export{getExportDefaultsByAst};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{createStyleImportPlugin}from"vite-plugin-style-import";const UIStyleResolve=()=>({libraryName:"@das-fed/ui",base:"@das-fed/ui/style/index.css"}),businessUIStyleResolve=()=>({libraryName:"@das-fed/ui/packages/business",base:"@das-fed/ui/style/business.css"}),DasUIStyleImport=(e={})=>!e.disabled&&e.styleResolve?createStyleImportPlugin({resolves:[UIStyleResolve(),businessUIStyleResolve()]}):null;export{DasUIStyleImport};
|
@@ -0,0 +1 @@
|
|
1
|
+
export*from"./core/style.js";
|
@@ -0,0 +1 @@
|
|
1
|
+
import{resolve}from"path";const dasFeWeb=e=>{let r;return{name:"das-fe-web",config:(e,{})=>({resolve:{alias:{"@":resolve(process.cwd(),"src")}}}),configResolved(e){r=e},buildStart:async()=>{r.cwd=resolve(process.cwd())},transformIndexHtml:{order:"post",handler:()=>{let e="development"===r.mode?"./config.local.js":"./config.js";return[{tag:"script",attrs:{src:e}}]}}}};export{dasFeWeb};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{dasFeWeb}from"./das-fe-web/index.js";import{DasUIStyleImport}from"./das-fe-ui/index.js";const dasFeWebVitePlugin=(e={})=>{var{dasWeb:e={},dasUI:s={disabled:!1,styleResolve:!0}}=e||{};return[dasFeWeb(e),DasUIStyleImport(s)]};export{dasFeWebVitePlugin};
|