@moneko/core 3.0.0-beta.48 → 3.0.0-beta.49
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/lib/generate-api.js +9 -5
- package/lib/process-env.d.ts +3 -3
- package/lib/process-env.js +1 -1
- package/package.json +1 -1
package/lib/generate-api.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import{readdir as e,stat as t,access as
|
|
1
|
+
import{readdir as e,stat as t,access as n,constants as r,existsSync as i,mkdirSync as l,readFile as s,readFileSync as o,rmdirSync as u,statSync as c,watch as p,writeFile as a,unlink as f}from"fs";import{join as g}from"path";import d from"typescript";import{APPTYPE as m,PROGRAMPATH as y,frameworkCacheDir as $}from"./process-env.js";let{ScriptKind:x,ScriptTarget:h,createSourceFile:b,forEachChild:F,getLeadingCommentRanges:T,isInterfaceDeclaration:C,isQuestionToken:S,isPropertySignature:j}=d;function D(e){let t=T(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end);return n.replace(/\/\*\*?\s*|\s*\*\//g,"").trim()}return null}function k(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function B(e){return e?.replace(/\*/g,"\\*").replace(/\|/g,"\\|")||"-"}let E=["#9C27B0","#673AB7","#3F51B5","#2196F3","#00BCD4","#009688","#4CAF50","#CDDC39","#FF9800","#795548"];function v(e){return e?e.replace(/\* @default\s+([^(|\n)]+)/,"").replace(/\* @since\s+([^\n]+)/,"").replace(/\* @see\s+{@link\s+(.+?)(?:\|(.+?))?}/,"").replace(/(\n\s+)+/g,"<br />").replace(/(<br \/>)$/g,""):null}function K(){}let O=g($,"./apis"),q={};function w(e,t){i($)||l($),i(O)||l(O);let n=e.split("/").slice(-2),r=g(O,n[0]),u=n[1].replace(/\.tsx?/,".md");i(r)||l(r),q[n[0]]||(q[n[0]]=[]);let c=q[n[0]].indexOf(u),p=g(r,u);if("deleted"===t)f(p,K),-1!==c&&q[n[0]].splice(c,1);else{let t=function(e){let t=o(e,"utf-8"),n=b(e,t,h.Latest,!0,x.TS),r="";return F(n,e=>{C(e)?r+=function(e){let t=D(e),n=k(t),r=v(t),i=e.name.text,l=r?`<n-typography type="secondary">${i}</n-typography>`:i,s=(function(e){let t=[];if(e.heritageClauses){for(let n of e.heritageClauses)if(n.token===d.SyntaxKind.ExtendsKeyword)for(let e of n.types)t.push(e.getText())}return t})(e)?.map((e,t)=>`<n-tag color="${E[t]}">${e}</n-tag>`),o=[r,l,n&&`<sup><n-typography type="success">${n}</n-typography></sup>`,s.length>0&&`<sub>\`extends\`</sub> ${s.join(" ")}`].filter(Boolean).join(" "),u=`## ${o}
|
|
2
2
|
|
|
3
|
-
| 属性 | 说明 | 类型 | 默认值 | 版本 |
|
|
4
|
-
|
|
|
5
|
-
`;for(let t of e.members)if(
|
|
6
|
-
`}return
|
|
3
|
+
| 属性 | 必要 | 说明 | 类型 | 默认值 | 版本 |
|
|
4
|
+
| -- | -- | -- | -- | -- | -- |
|
|
5
|
+
`;for(let t of e.members)if(j(t)){let e=B(t.name.getText()),n=t.questionToken&&S(t.questionToken),r=D(t),i=B(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(r)),l=B(k(r)),s=function(e,t){if(!e||!t)return null;let n=e.match(/@see\s+{@link\s+([^|}]+)(?:\|([^}]+))?}/);if(n){let e=n[2]||t;return t.replace(new RegExp(e),`[${e}](${n[1]})`)}return t}(r,B(t.type?.getText())),o=B(v(r)),c=`<n-typography type="${n?"error":"success"}">${n?"✘":"✔"}</n-typography>`;u+=`| ${e} | ${c} | ${o} | ${s} | ${i} | ${l} |
|
|
6
|
+
`}return u+"\n"}(e):d.isEnumDeclaration(e)&&(r+=function(e){let t=e.name.text,n=`## ${t}
|
|
7
|
+
| 属性 | 说明 | 值 | 版本 |
|
|
8
|
+
| -- | -- | -- | -- |
|
|
9
|
+
`;for(let t of e.members){let e=B(t.name.getText()),r=D(t),i=B(function(e){let t=e.initializer;return t&&d.isStringLiteral(t)?` '${t.text}'`:null}(t)),l=B(k(r)),s=B(r?.replace(/\* @since\s+([^\n]+)/,"").replace(/(\n\s+)+/g,"<br />").replace(/(<br \/>)$/g,""));n+=`| ${e} | ${s} | ${i} | ${l} |
|
|
10
|
+
`}return n+"\n"}(e))}),r}(e);t?(a(p,t,"utf-8",K),-1===c&&q[n[0]].push(u)):(f(p,K),-1!==c&&q[n[0]].splice(c,1))}s(g(O,"index.js"),{encoding:"utf-8"},(e,t)=>{let n=`export default ${JSON.stringify(q)};`;if(e){a(g(O,"index.js"),n,"utf-8",K);return}t!==n&&a(g(O,"index.js"),n,"utf-8",K)})}if("library"===m){let i=g(y,"./components");!function n(r,i=1){e(r,(e,l)=>{e||l.forEach(e=>{let l=g(r,e);t(l,(t,r)=>{!t&&(i?r.isDirectory()&&n(l,i-1):r.isFile()&&(e.endsWith(".ts")||e.endsWith(".tsx"))&&w(l,"added"))})})})}(i),function(e){p(e,{recursive:!0},(t,i)=>{let l=g(e,i||"");c(l).isDirectory()||("change"===t?w(l,t):"rename"===t&&n(l,r.F_OK,e=>{e?w(l,"deleted"):w(l,"added")}))})}(i),process.on("SIGINT",function(){try{u(O,{recursive:!0})}catch(e){}process.exit()})}
|
package/lib/process-env.d.ts
CHANGED
|
@@ -8,12 +8,12 @@ export declare const jsxImportSource: string;
|
|
|
8
8
|
export declare const PROGRAMPATH: string;
|
|
9
9
|
export declare const PACKAGENAME: string;
|
|
10
10
|
export declare const PACKAGEVERSION: string;
|
|
11
|
-
export declare const frameworkCacheDir: ".git/";
|
|
12
|
-
export declare const cacheDir: string;
|
|
13
11
|
export declare const pkgName: string;
|
|
12
|
+
export declare const DEV: boolean;
|
|
13
|
+
export declare const frameworkCacheDir: ".git/" | `node_modules/.cache/${string}`;
|
|
14
|
+
export declare const cacheDir: string;
|
|
14
15
|
export declare const NODE_ENV: string | undefined;
|
|
15
16
|
export declare const CUSTOMCONFIG: string | undefined;
|
|
16
|
-
export declare const DEV: boolean;
|
|
17
17
|
export declare let hasEslintConfig: boolean;
|
|
18
18
|
export declare let hasStylelintConfig: boolean;
|
|
19
19
|
export declare const hasAntd: boolean;
|
package/lib/process-env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as e,existsSync as o,mkdirSync as r}from"fs";import{join as t}from"path";import s from"url";import{hasPkg as n}from"./has-pkg.js";import{resolveProgramPath as p}from"./utils.js";import c from"./yarn-argv.js";export const __dirname=s.fileURLToPath(new URL(".",import.meta.url));export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isReact="react"===FRAMEWORK;export const isSolid="solid-js"===FRAMEWORK;export const jsxImportSource={react:"react","solid-js":"solid-js/h"}[FRAMEWORK];export const PROGRAMPATH=process.cwd();export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let a=e(t(__dirname,"../package.json"),{encoding:"utf-8"});export const frameworkCacheDir=p(".git/");export const cacheDir=t(PROGRAMPATH,"./node_modules/.cache/@moneko/cli/");o(cacheDir)||r(cacheDir,{recursive:!0});export const
|
|
1
|
+
import{readFileSync as e,existsSync as o,mkdirSync as r}from"fs";import{join as t}from"path";import s from"url";import{hasPkg as n}from"./has-pkg.js";import{resolveProgramPath as p}from"./utils.js";import c from"./yarn-argv.js";export const __dirname=s.fileURLToPath(new URL(".",import.meta.url));export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isReact="react"===FRAMEWORK;export const isSolid="solid-js"===FRAMEWORK;export const jsxImportSource={react:"react","solid-js":"solid-js/h"}[FRAMEWORK];export const PROGRAMPATH=process.cwd();export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let a=e(t(__dirname,"../package.json"),{encoding:"utf-8"});export const pkgName=JSON.parse(a).name;export const DEV="development"===process.env.NODE_ENV;export const frameworkCacheDir=p(DEV?".git/":`node_modules/.cache/${PACKAGENAME}`);export const cacheDir=t(PROGRAMPATH,"./node_modules/.cache/@moneko/cli/");o(cacheDir)||r(cacheDir,{recursive:!0});export const NODE_ENV=process.env.NODE_ENV;export const CUSTOMCONFIG=process.env.npm_config_config||c.config;export let hasEslintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_eslintConfig_")).length;export let hasStylelintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_stylelint_")).length;export const hasAntd=n("antd");export const programInfo={name:PACKAGENAME,version:PACKAGEVERSION,type:APPTYPE,description:process.env.npm_package_description,author:{name:process.env.npm_package_author_name,email:process.env.npm_package_author_email,url:process.env.npm_package_author_url},repository:{type:process.env.npm_package_repository_type,url:process.env.npm_package_repository_url,directory:process.env.npm_package_repository_directory}};if(parseInt(process.versions.node)>14){let o=e(p("package.json"),{encoding:"utf-8"}),{description:r,author:t,repository:s,eslintConfig:n,stylelint:c}=JSON.parse(o);programInfo.author="string"==typeof t?{name:t}:t,programInfo.repository="string"==typeof t?{url:s}:s,programInfo.description=r,hasEslintConfig=!!n,hasStylelintConfig=!!c}
|