anl 26.228.0 → 26.305.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.
@@ -1,3 +1,3 @@
1
- const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../utils/index.cjs`),n=require(`./utils.cjs`);let r=require(`child_process`),i=require(`fs`);i=e.__toESM(i);let a=require(`path`);a=e.__toESM(a);const o=async()=>{let e=a.default.join(__dirname,`..`,`..`,`git-local-config`),o=process.cwd(),s=a.default.join(e,`.gitscripts`),c=a.default.join(o,`.gitscripts`);await n.pathExists(s)?(await n.copyDirectoryRecursive(s,c),t.log.success(`.gitscripts create done.`)):t.log.error(`source directory ${s} does not exist`);for(let r of[`.gitconfig`,`.commit-type.cjs`]){let i=a.default.join(e,r),s=a.default.join(o,r);await n.pathExists(i)?await n.copyFileIfMissing(i,s):t.log.error(`source file ${i} does not exist`)}try{i.default.chmodSync(a.default.join(c,`random-branch.sh`),493),t.log.success(`random-branch.sh Raise power`)}catch(e){console.log(e),t.log.error(`Set .githooks/commit-msg executable permission failed: ${e instanceof Error?e.message:String(e)}`)}try{(0,r.execSync)(`git config --local include.path ../.gitconfig`,{stdio:`ignore`}),t.log.success(`.gitconfig git set`)}catch(e){console.log(e),t.log.error(`Execute git config --local include.path ../.gitconfig failed, please execute the command manually`)}},s=async()=>{let e=a.default.join(__dirname,`..`,`..`,`git-local-config`,`.githooks`),o=process.cwd(),s=a.default.join(o,`.githooks`);if(!await n.pathExists(e)){t.log.error(`source directory ${e} does not exist`);return}await n.copyDirectoryRecursive(e,s),t.log.success(`.githooks create done.`);try{i.default.chmodSync(a.default.join(s,`commit-msg`),493),t.log.success(`commit-msg raise power done.`)}catch(e){console.log(e),t.log.error(`Set .githooks/commit-msg executable permission failed: ${e instanceof Error?e.message:String(e)}`)}try{(0,r.execSync)(`git config core.hooksPath .githooks`,{stdio:`ignore`}),t.log.success(`git set .githooks done.`)}catch(e){console.log(e),t.log.error(`Execute [git config core.hooksPath .githooks] failed, please execute the command manually`)}},c=async()=>{let e=a.default.join(__dirname,`..`,`..`,`git-local-config`),r=process.cwd(),i=a.default.join(e,`.gitattributes`),o=a.default.join(r,`.gitattributes`);if(!await n.pathExists(i)){t.log.error(`source file ${i} does not exist`);return}await n.copyFileIfMissing(i,o)},l=async(e=[])=>{e.includes(`gitflow`)&&await o(),e.includes(`commitSubject`)&&await s(),e.includes(`customGitCommand`)&&await c(),console.log(`
1
+ const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../utils/index.cjs`),n=require(`./utils.cjs`);let r=require(`child_process`),i=require(`fs`);i=e.__toESM(i);let a=require(`path`);a=e.__toESM(a);const o=async()=>{let e=__dirname,o=process.cwd(),s=a.default.join(e,`.gitscripts`),c=a.default.join(o,`.gitscripts`);await n.pathExists(s)?(await n.copyDirectoryRecursive(s,c),t.log.success(`.gitscripts create done.`)):t.log.error(`source directory ${s} does not exist`);for(let r of[`.gitconfig`,`.commit-type.cjs`]){let i=a.default.join(e,r),s=a.default.join(o,r);await n.pathExists(i)?await n.copyFileIfMissing(i,s):t.log.error(`source file ${i} does not exist`)}try{i.default.chmodSync(a.default.join(c,`random-branch.sh`),493),t.log.success(`random-branch.sh Raise power`)}catch(e){console.log(e),t.log.error(`Set .githooks/commit-msg executable permission failed: ${e instanceof Error?e.message:String(e)}`)}try{(0,r.execSync)(`git config --local include.path ../.gitconfig`,{stdio:`ignore`}),t.log.success(`.gitconfig git set`)}catch(e){console.log(e),t.log.error(`Execute git config --local include.path ../.gitconfig failed, please execute the command manually`)}},s=async()=>{let e=a.default.join(__dirname,`.githooks`),o=process.cwd(),s=a.default.join(o,`.githooks`);if(!await n.pathExists(e)){t.log.error(`source directory ${e} does not exist`);return}await n.copyDirectoryRecursive(e,s),t.log.success(`.githooks create done.`);try{i.default.chmodSync(a.default.join(s,`commit-msg`),493),t.log.success(`commit-msg raise power done.`)}catch(e){console.log(e),t.log.error(`Set .githooks/commit-msg executable permission failed: ${e instanceof Error?e.message:String(e)}`)}try{(0,r.execSync)(`git config core.hooksPath .githooks`,{stdio:`ignore`}),t.log.success(`git set .githooks done.`)}catch(e){console.log(e),t.log.error(`Execute [git config core.hooksPath .githooks] failed, please execute the command manually`)}},c=async()=>{let e=__dirname,r=process.cwd(),i=a.default.join(e,`.gitattributes`),o=a.default.join(r,`.gitattributes`);if(!await n.pathExists(i)){t.log.error(`source file ${i} does not exist`);return}await n.copyFileIfMissing(i,o)},l=async(e=[])=>{e.includes(`gitflow`)&&await o(),e.includes(`commitSubject`)&&await s(),e.includes(`customGitCommand`)&&await c(),console.log(`
2
2
  `),t.log.warning(`please run [git nb] command to create a new branch.`),console.log(`
3
3
  `)};exports.gitHandle=l;
package/lib/package.cjs CHANGED
@@ -1 +1 @@
1
- var e=`26.228.0`;Object.defineProperty(exports,`version`,{enumerable:!0,get:function(){return e}});
1
+ var e=`26.305.0`;Object.defineProperty(exports,`version`,{enumerable:!0,get:function(){return e}});
@@ -1,6 +1,5 @@
1
1
  const e=require(`../../utils/index.cjs`),t=require(`../shared/format.cjs`),n=require(`../shared/naming.cjs`),r=require(`../shared/schema-utils.cjs`),i=require(`./enum-parser.cjs`);var a=class{schemas;config;requiredFieldSet=new Set;defaultReturn={headerRef:``,renderStr:``,comment:``,typeName:``};enumParser;schemasMap=new Map;constructor(e,t){this.schemas=e,this.config=t,this.enumParser=new i.EnumParser(t)}nullable(e){return r.nullableSuffix(e)}isRequired(e){return this.requiredFieldSet.has(e)}stringifyValue(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}buildDocComment(e,n){let r=t.getIndentation(this.config),i=[],a=e,o=a.title,s=a.description;o&&i.push(`@title ${o}`),s&&s.split(`
2
- `).forEach((e,t)=>i.push(t===0?`@description ${e}`:e)),`deprecated`in e&&e.deprecated&&i.push(`@deprecated`),`default`in e&&e.default!==void 0&&i.push(`@default ${this.stringifyValue(e.default)}`),`example`in e&&e.example!==void 0&&i.push(`@example ${this.stringifyValue(e.example)}`),`format`in e&&e.format&&i.push(`@format ${e.format}`);let c=[[`pattern`,`@pattern`],[`minimum`,`@minimum`],[`maximum`,`@maximum`],[`exclusiveMinimum`,`@exclusiveMinimum`],[`exclusiveMaximum`,`@exclusiveMaximum`],[`minLength`,`@minLength`],[`maxLength`,`@maxLength`],[`minItems`,`@minItems`],[`maxItems`,`@maxItems`]],l=e;if(c.some(([e])=>l[e]!==void 0)){let e=c.map(([e,t])=>l[e]===void 0?``:`${t} ${this.stringifyValue(l[e])}`).filter(Boolean);i.push(...e)}if(!i.length)return``;if(i.length===1&&!i[0].includes(`
3
- `))return`${r}/** ${i[0]} */`;let u=[`${r}/**`];return i.forEach(e=>{e&&(e.includes(`
2
+ `).forEach((e,t)=>i.push(t===0?`@description ${e}`:e)),`deprecated`in e&&e.deprecated&&i.push(`@deprecated`),`default`in e&&e.default!==void 0&&i.push(`@default ${this.stringifyValue(e.default)}`),`example`in e&&e.example!==void 0&&i.push(`@example ${this.stringifyValue(e.example)}`),`format`in e&&e.format&&i.push(`@format ${e.format}`);let c=[[`pattern`,`@pattern`],[`minimum`,`@minimum`],[`maximum`,`@maximum`],[`exclusiveMinimum`,`@exclusiveMinimum`],[`exclusiveMaximum`,`@exclusiveMaximum`],[`minLength`,`@minLength`],[`maxLength`,`@maxLength`],[`minItems`,`@minItems`],[`maxItems`,`@maxItems`]],l=e;if(c.some(([e])=>l[e]!==void 0)){let e=c.map(([e,t])=>l[e]===void 0?``:`${t} ${this.stringifyValue(l[e])}`).filter(Boolean);i.push(...e)}if(!i.length)return``;let u=[`${r}/**`];return i.forEach(e=>{e&&(e.includes(`
4
3
  `)?e.split(`
5
4
  `).forEach(e=>u.push(`${r} * ${e}`)):u.push(`${r} * ${e}`))}),u.push(`${r} */`),u.join(`
6
5
  `)}nameTheHumpCenterStroke(e){let t=e.replace(`#/components/schemas/`,``),r=n.resolveSchemaName(t),i={typeName:r,fileName:n.typeNameToFileName(r),dataType:``};if(this.schemas){let e=this.schemas[t];e?.enum?i.dataType=`enum`:i.dataType=e?.type}return i}parseRef(e){if(!e?.trim())return{headerRefStr:``,typeName:``,dataType:``};let{fileName:t,typeName:r,dataType:i=``}=this.nameTheHumpCenterStroke(e),a;return a=i===`enum`?`import type { ${n.getEnumTypeName(this.config,r)} } from '${this.config.importEnumPath}';`:`import type { ${r} } from './${t}';`,{headerRefStr:a,typeName:r,dataType:i}}parseArray(r,i){let a=r,{items:o={},nullable:s}=a,c=o?.$ref;if(c){let{headerRefStr:r,typeName:o,dataType:l}=this.parseRef(c),u=a.example;if(l===`enum`&&typeof u==`string`&&e.isValidJSON(u)){let e=this.enumParser.convertJsonToEnumString(u,o);this.enumParser.addEnumByName(o,e)}let d=l===`enum`?n.getEnumTypeName(this.config,o):o;return{headerRef:r,renderStr:`${t.getIndentation(this.config)}${i}${this.isRequired(i)?``:`?`}: Array<${d}>${this.nullable(s)};`,typeName:d}}let l=o?.type,u=l===`integer`?`number`:l;return l===`object`&&(u=`Record<string, unknown>`),{headerRef:``,renderStr:`${t.getIndentation(this.config)}${i}${this.isRequired(i)?``:`?`}: Array<${u}>${this.nullable(s)};`,typeName:u}}parseBoolean(e,n){return e.type===`boolean`?`${t.getIndentation(this.config)}${n}${this.isRequired(n)?``:`?`}: boolean${this.nullable(e.nullable)};`:``}parseInteger(e,n){return Array.isArray(e.enum)?this.enumParser.handleEnum(e,n,this.isRequired(n))?.renderStr??``:`${t.getIndentation(this.config)}${n}${this.isRequired(n)?``:`?`}: number${this.nullable(e.nullable)};`}parseNumber(e,n){if(e.type!==`number`)return null;if(e.enum){let t=this.enumParser.handleEnum(e,n,this.isRequired(n));if(t)return t}return{headerRef:``,renderStr:`${t.getIndentation(this.config)}${n}${this.isRequired(n)?``:`?`}: number${this.nullable(e.nullable)};`}}getStringTypeByFormat(e){if(!e)return`string`;switch(e){case`date-time`:case`date`:case`time`:return`Date`;case`email`:case`idn-email`:case`uuid`:case`uri`:case`uri-reference`:case`iri`:case`iri-reference`:case`hostname`:case`idn-hostname`:case`ipv4`:case`ipv6`:return`string`;case`binary`:return`File`;default:return`string`}}parseString(e,n){if(e.type!==`string`)return null;if(e.enum){let t=this.enumParser.handleEnum(e,n,this.isRequired(n));if(t)return t}let r=this.getStringTypeByFormat(e.format);return{headerRef:``,renderStr:`${t.getIndentation(this.config)}${n}${this.isRequired(n)?``:`?`}: ${r}${this.nullable(e.nullable)};`}}parseObject(e,n){let r=``,i=``;if(e.type===`object`){let a=e;if(typeof a.additionalProperties==`object`){let e=this.parseArray(a.additionalProperties,n)??this.defaultReturn;r=e?.headerRef??``,i=e?.renderStr??``}i=typeof a.additionalProperties==`boolean`?`${t.getIndentation(this.config)}${n}${this.isRequired(n)?``:`?`}: Record<string, unknown>${this.nullable(a.nullable)};`:`${t.getIndentation(this.config)}${n}${this.isRequired(n)?``:`?`}: ${e.type}${this.nullable(e.nullable)};`}return{headerRef:r,renderStr:i}}parseProperties(r,i){let a=[],o=[];if(!r)return{headerRef:``,renderStr:`export interface ${i} {}`};let s=Object.keys(r).sort();for(let c of s){let s=r[c];if(s?.$ref){let{headerRefStr:r,typeName:l,dataType:u}=this.parseRef(s.$ref);!o.includes(r)&&l!==i&&o.push(r);let d=s,f=this.buildDocComment(d,c);f!==``&&a.push(f);let p=u===`enum`?n.getEnumTypeName(this.config,l):l;a.push(`${t.getIndentation(this.config)}${c}${this.isRequired(c)?``:`?`}: ${p};`);let m=s.example;if(u===`enum`&&m&&e.isValidJSON(m)){let e=this.enumParser.convertJsonToEnumString(m,l);this.enumParser.addEnumByName(l,e)}continue}if(`allOf`in s){let e=s.allOf?.[0];if(e?.$ref){let{headerRefStr:r,typeName:l,dataType:u}=this.parseRef(e.$ref),d=u===`enum`?n.getEnumTypeName(this.config,l):l;!o.includes(r)&&l!==i&&o.push(r);let f=s,p=this.buildDocComment(f,c);p!==``&&a.push(p),a.push(`${t.getIndentation(this.config)}${c}${this.isRequired(c)?``:`?`}: ${d}${this.nullable(s.nullable)};`);continue}}let l=s,u=this.buildDocComment(l,c);switch(u!==``&&a.push(u),l.type){case`array`:{let e=this.parseArray(l,c)??this.defaultReturn;a.push(e?.renderStr??``),!o.includes(e.headerRef)&&i!==e.typeName&&o.push(e.headerRef)}break;case`boolean`:a.push(this.parseBoolean(l,c));break;case`integer`:a.push(this.parseInteger(l,c));break;case`number`:{let e=this.parseNumber(l,c);e&&(e.headerRef&&!o.includes(e.headerRef)&&o.push(e.headerRef),a.push(e.renderStr))}break;case`string`:if(l.enum){let e=this.enumParser.handleEnum(l,c,this.isRequired(c));e&&(e.headerRef&&!o.includes(e.headerRef)&&o.push(e.headerRef),e.renderStr&&a.push(e.renderStr))}else a.push(this.parseString(l,c)?.renderStr??``);break;case`object`:{let{headerRef:e,renderStr:t}=this.parseObject(l,c)??this.defaultReturn;a.push(t),o.includes(e)||o.push(e)}break}}let c=[`export interface ${i} {`,...a,`}`];if(o.length>0){let e=o.filter(e=>e!==``);e.length>0&&e.push(``),c.unshift(...e)}let l=c.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anl",
3
- "version": "26.228.0",
3
+ "version": "26.305.0",
4
4
  "description": "FE command line tool",
5
5
  "main": "bin/an-cli.js",
6
6
  "publishConfig": {
@@ -12,7 +12,7 @@
12
12
  "build": "rimraf lib && tsdown",
13
13
  "pub": "bash publish.sh",
14
14
  "ts": "tsc ./src/int.ts --noEmit --watch",
15
- "blink": "npm run build && npm link",
15
+ "blink": "pnpm run build && pnpm link",
16
16
  "docs": "docsify serve ./docs"
17
17
  },
18
18
  "bin": {
@@ -98,7 +98,6 @@
98
98
  "url": "git+https://github.com/bianliuzhu/an-cli.git"
99
99
  },
100
100
  "homepage": "https://bianliuzhu.github.io/an-cli/#/",
101
- "type": "commonjs",
102
101
  "lint-staged": {
103
102
  "*.{ts,js,mjs,cjs}": [
104
103
  "eslint --fix"