@tikkhun/index-generator 0.0.1 → 0.0.3

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';var cliCore=require('@tikkhun/cli-core'),glob=require('glob'),g=require('fs/promises');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var g__default=/*#__PURE__*/_interopDefault(g);/**
3
- index-generator
2
+ 'use strict';var cliCore=require('@tikkhun/cli-core'),utilsCore=require('@tikkhun/utils-core'),x=require('fs/promises'),glob=require('glob'),c=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var x__default=/*#__PURE__*/_interopDefault(x);var c__default=/*#__PURE__*/_interopDefault(c);/**
3
+ @tikkhun/index-generator
4
4
  */
5
- var r=(e,s,t)=>new Promise((d,n)=>{var x=i=>{try{a(t.next(i));}catch(p){n(p);}},f=i=>{try{a(t.throw(i));}catch(p){n(p);}},a=i=>i.done?d(i.value):Promise.resolve(i.value).then(x,f);a((t=t.apply(e,s)).next());});var o={name:"index-generator",version:"0.0.1",description:""};function c(e,s){return r(this,null,function*(){try{let d=(yield glob.glob(e)).map(n=>`export * from "${n}";`).join(`
6
- `);yield g__default.default.writeFile((s==null?void 0:s.indexName)||"index.ts",d,"utf-8");}catch(t){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",t);}})}var y={workspace:"."},w={workspace:"\u8DEF\u5F84"},v={workspace:"string"},h={name:o.name,version:o.version,description:o.description,types:[cliCore.CommandTypes.args,cliCore.CommandTypes.prompts],defaultOptions:y,optionTitles:w,optionTypes:v,action:e=>r(null,null,function*(){c(e==null?void 0:e.workspace);})},m=new cliCore.Cli(h);m.start();
5
+ var h=Object.defineProperty;var f=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var g=(n,e,t)=>e in n?h(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t,y=(n,e)=>{for(var t in e||(e={}))v.call(e,t)&&g(n,t,e[t]);if(f)for(var t of f(e))O.call(e,t)&&g(n,t,e[t]);return n};var o=(n,e,t)=>new Promise((u,r)=>{var d=i=>{try{p(t.next(i));}catch(l){r(l);}},s=i=>{try{p(t.throw(i));}catch(l){r(l);}},p=i=>i.done?u(i.value):Promise.resolve(i.value).then(d,s);p((t=t.apply(n,e)).next());});var a={name:"@tikkhun/index-generator",version:"0.0.3",description:""};var m={cwd:".",indexName:"index.ts",include:"*",exclude:[]};function k(n){return o(this,null,function*(){try{let e=utilsCore.mergeOptions(m,n),t=c__default.default.resolve(e.cwd),r=(yield glob.glob(e.include,{cwd:t,ignore:e.exclude})).map(s=>`export * from "./${c__default.default.extname(s)?c__default.default.basename(s).split(c__default.default.extname(s))[0]:s}";`).join(`
6
+ `);console.log(r);let d=(e==null?void 0:e.indexName)||"index.ts";if(yield C(d)){console.error("index.ts \u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA");return}yield x__default.default.writeFile(d,r,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function C(n){return o(this,null,function*(){try{return yield x__default.default.access(n,x__default.default.constants.F_OK),!0}catch(e){return false}})}var F=y({},m),N={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664"},T={cwd:"string",indexName:"string",include:"array",exclude:"array"},E={name:a.name,version:a.version,description:a.description,types:[cliCore.CommandTypes.args,cliCore.CommandTypes.prompts],defaultOptions:F,optionTitles:N,optionTypes:T,action:n=>o(null,null,function*(){k(n);})},w=new cliCore.Cli(E);w.start();
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import {CommandTypes,Cli}from'@tikkhun/cli-core';import {glob}from'glob';import g from'fs/promises';/**
3
- index-generator
2
+ import {CommandTypes,Cli}from'@tikkhun/cli-core';import {mergeOptions}from'@tikkhun/utils-core';import x from'fs/promises';import {glob}from'glob';import c from'path';/**
3
+ @tikkhun/index-generator
4
4
  */
5
- var r=(e,s,t)=>new Promise((d,n)=>{var x=i=>{try{a(t.next(i));}catch(p){n(p);}},f=i=>{try{a(t.throw(i));}catch(p){n(p);}},a=i=>i.done?d(i.value):Promise.resolve(i.value).then(x,f);a((t=t.apply(e,s)).next());});var o={name:"index-generator",version:"0.0.1",description:""};function c(e,s){return r(this,null,function*(){try{let d=(yield glob(e)).map(n=>`export * from "${n}";`).join(`
6
- `);yield g.writeFile((s==null?void 0:s.indexName)||"index.ts",d,"utf-8");}catch(t){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",t);}})}var y={workspace:"."},w={workspace:"\u8DEF\u5F84"},v={workspace:"string"},h={name:o.name,version:o.version,description:o.description,types:[CommandTypes.args,CommandTypes.prompts],defaultOptions:y,optionTitles:w,optionTypes:v,action:e=>r(null,null,function*(){c(e==null?void 0:e.workspace);})},m=new Cli(h);m.start();
5
+ var h=Object.defineProperty;var f=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var g=(n,e,t)=>e in n?h(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t,y=(n,e)=>{for(var t in e||(e={}))v.call(e,t)&&g(n,t,e[t]);if(f)for(var t of f(e))O.call(e,t)&&g(n,t,e[t]);return n};var o=(n,e,t)=>new Promise((u,r)=>{var d=i=>{try{p(t.next(i));}catch(l){r(l);}},s=i=>{try{p(t.throw(i));}catch(l){r(l);}},p=i=>i.done?u(i.value):Promise.resolve(i.value).then(d,s);p((t=t.apply(n,e)).next());});var a={name:"@tikkhun/index-generator",version:"0.0.3",description:""};var m={cwd:".",indexName:"index.ts",include:"*",exclude:[]};function k(n){return o(this,null,function*(){try{let e=mergeOptions(m,n),t=c.resolve(e.cwd),r=(yield glob(e.include,{cwd:t,ignore:e.exclude})).map(s=>`export * from "./${c.extname(s)?c.basename(s).split(c.extname(s))[0]:s}";`).join(`
6
+ `);console.log(r);let d=(e==null?void 0:e.indexName)||"index.ts";if(yield C(d)){console.error("index.ts \u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA");return}yield x.writeFile(d,r,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function C(n){return o(this,null,function*(){try{return yield x.access(n,x.constants.F_OK),!0}catch(e){return false}})}var F=y({},m),N={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664"},T={cwd:"string",indexName:"string",include:"array",exclude:"array"},E={name:a.name,version:a.version,description:a.description,types:[CommandTypes.args,CommandTypes.prompts],defaultOptions:F,optionTitles:N,optionTypes:T,action:n=>o(null,null,function*(){k(n);})},w=new Cli(E);w.start();
@@ -2,13 +2,22 @@ import * as _tikkhun_cli_core from '@tikkhun/cli-core';
2
2
  import { CommandTypes } from '@tikkhun/cli-core';
3
3
 
4
4
  declare const defaultOptions: {
5
- workspace: string;
5
+ cwd: string;
6
+ indexName: string;
7
+ include: string;
8
+ exclude: never[];
6
9
  };
7
10
  declare const optionTitles: {
8
- workspace: string;
11
+ cwd: string;
12
+ indexName: string;
13
+ include: string;
14
+ exclude: string;
9
15
  };
10
16
  declare const optionTypes: {
11
- workspace: string;
17
+ cwd: string;
18
+ indexName: string;
19
+ include: string;
20
+ exclude: string;
12
21
  };
13
22
  declare const cliOptions: {
14
23
  name: string;
@@ -16,13 +25,22 @@ declare const cliOptions: {
16
25
  description: string;
17
26
  types: CommandTypes[];
18
27
  defaultOptions: {
19
- workspace: string;
28
+ cwd: string;
29
+ indexName: string;
30
+ include: string;
31
+ exclude: never[];
20
32
  };
21
33
  optionTitles: {
22
- workspace: string;
34
+ cwd: string;
35
+ indexName: string;
36
+ include: string;
37
+ exclude: string;
23
38
  };
24
39
  optionTypes: {
25
- workspace: string;
40
+ cwd: string;
41
+ indexName: string;
42
+ include: string;
43
+ exclude: string;
26
44
  };
27
45
  action: (options: any) => Promise<void>;
28
46
  };
@@ -2,13 +2,22 @@ import * as _tikkhun_cli_core from '@tikkhun/cli-core';
2
2
  import { CommandTypes } from '@tikkhun/cli-core';
3
3
 
4
4
  declare const defaultOptions: {
5
- workspace: string;
5
+ cwd: string;
6
+ indexName: string;
7
+ include: string;
8
+ exclude: never[];
6
9
  };
7
10
  declare const optionTitles: {
8
- workspace: string;
11
+ cwd: string;
12
+ indexName: string;
13
+ include: string;
14
+ exclude: string;
9
15
  };
10
16
  declare const optionTypes: {
11
- workspace: string;
17
+ cwd: string;
18
+ indexName: string;
19
+ include: string;
20
+ exclude: string;
12
21
  };
13
22
  declare const cliOptions: {
14
23
  name: string;
@@ -16,13 +25,22 @@ declare const cliOptions: {
16
25
  description: string;
17
26
  types: CommandTypes[];
18
27
  defaultOptions: {
19
- workspace: string;
28
+ cwd: string;
29
+ indexName: string;
30
+ include: string;
31
+ exclude: never[];
20
32
  };
21
33
  optionTitles: {
22
- workspace: string;
34
+ cwd: string;
35
+ indexName: string;
36
+ include: string;
37
+ exclude: string;
23
38
  };
24
39
  optionTypes: {
25
- workspace: string;
40
+ cwd: string;
41
+ indexName: string;
42
+ include: string;
43
+ exclude: string;
26
44
  };
27
45
  action: (options: any) => Promise<void>;
28
46
  };
@@ -1,5 +1,5 @@
1
- 'use strict';var cliCore=require('@tikkhun/cli-core'),glob=require('glob'),b=require('fs/promises');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var b__default=/*#__PURE__*/_interopDefault(b);/**
2
- index-generator
1
+ 'use strict';var cliCore=require('@tikkhun/cli-core'),utilsCore=require('@tikkhun/utils-core'),x=require('fs/promises'),glob=require('glob'),c=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var x__default=/*#__PURE__*/_interopDefault(x);var c__default=/*#__PURE__*/_interopDefault(c);/**
2
+ @tikkhun/index-generator
3
3
  */
4
- var r=(e,s,t)=>new Promise((d,n)=>{var m=i=>{try{a(t.next(i));}catch(p){n(p);}},x=i=>{try{a(t.throw(i));}catch(p){n(p);}},a=i=>i.done?d(i.value):Promise.resolve(i.value).then(m,x);a((t=t.apply(e,s)).next());});var o={name:"index-generator",version:"0.0.1",description:""};function c(e,s){return r(this,null,function*(){try{let d=(yield glob.glob(e)).map(n=>`export * from "${n}";`).join(`
5
- `);yield b__default.default.writeFile((s==null?void 0:s.indexName)||"index.ts",d,"utf-8");}catch(t){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",t);}})}var k={workspace:"."},y={workspace:"\u8DEF\u5F84"},w={workspace:"string"},v={name:o.name,version:o.version,description:o.description,types:[cliCore.CommandTypes.args,cliCore.CommandTypes.prompts],defaultOptions:k,optionTitles:y,optionTypes:w,action:e=>r(null,null,function*(){c(e==null?void 0:e.workspace);})},q=new cliCore.Cli(v);exports.cli=q;exports.cliOptions=v;exports.defaultOptions=k;exports.optionTitles=y;exports.optionTypes=w;
4
+ var w=Object.defineProperty;var f=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var g=(n,e,t)=>e in n?w(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t,y=(n,e)=>{for(var t in e||(e={}))h.call(e,t)&&g(n,t,e[t]);if(f)for(var t of f(e))O.call(e,t)&&g(n,t,e[t]);return n};var o=(n,e,t)=>new Promise((u,r)=>{var d=i=>{try{p(t.next(i));}catch(l){r(l);}},s=i=>{try{p(t.throw(i));}catch(l){r(l);}},p=i=>i.done?u(i.value):Promise.resolve(i.value).then(d,s);p((t=t.apply(n,e)).next());});var a={name:"@tikkhun/index-generator",version:"0.0.3",description:""};var m={cwd:".",indexName:"index.ts",include:"*",exclude:[]};function k(n){return o(this,null,function*(){try{let e=utilsCore.mergeOptions(m,n),t=c__default.default.resolve(e.cwd),r=(yield glob.glob(e.include,{cwd:t,ignore:e.exclude})).map(s=>`export * from "./${c__default.default.extname(s)?c__default.default.basename(s).split(c__default.default.extname(s))[0]:s}";`).join(`
5
+ `);console.log(r);let d=(e==null?void 0:e.indexName)||"index.ts";if(yield G(d)){console.error("index.ts \u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA");return}yield x__default.default.writeFile(d,r,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function G(n){return o(this,null,function*(){try{return yield x__default.default.access(n,x__default.default.constants.F_OK),!0}catch(e){return false}})}var D=y({},m),F={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664"},N={cwd:"string",indexName:"string",include:"array",exclude:"array"},T={name:a.name,version:a.version,description:a.description,types:[cliCore.CommandTypes.args,cliCore.CommandTypes.prompts],defaultOptions:D,optionTitles:F,optionTypes:N,action:n=>o(null,null,function*(){k(n);})},B=new cliCore.Cli(T);exports.cli=B;exports.cliOptions=T;exports.defaultOptions=D;exports.optionTitles=F;exports.optionTypes=N;
@@ -1,5 +1,5 @@
1
- import {CommandTypes,Cli}from'@tikkhun/cli-core';import {glob}from'glob';import b from'fs/promises';/**
2
- index-generator
1
+ import {CommandTypes,Cli}from'@tikkhun/cli-core';import {mergeOptions}from'@tikkhun/utils-core';import x from'fs/promises';import {glob}from'glob';import c from'path';/**
2
+ @tikkhun/index-generator
3
3
  */
4
- var r=(e,s,t)=>new Promise((d,n)=>{var m=i=>{try{a(t.next(i));}catch(p){n(p);}},x=i=>{try{a(t.throw(i));}catch(p){n(p);}},a=i=>i.done?d(i.value):Promise.resolve(i.value).then(m,x);a((t=t.apply(e,s)).next());});var o={name:"index-generator",version:"0.0.1",description:""};function c(e,s){return r(this,null,function*(){try{let d=(yield glob(e)).map(n=>`export * from "${n}";`).join(`
5
- `);yield b.writeFile((s==null?void 0:s.indexName)||"index.ts",d,"utf-8");}catch(t){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",t);}})}var k={workspace:"."},y={workspace:"\u8DEF\u5F84"},w={workspace:"string"},v={name:o.name,version:o.version,description:o.description,types:[CommandTypes.args,CommandTypes.prompts],defaultOptions:k,optionTitles:y,optionTypes:w,action:e=>r(null,null,function*(){c(e==null?void 0:e.workspace);})},q=new Cli(v);export{q as cli,v as cliOptions,k as defaultOptions,y as optionTitles,w as optionTypes};
4
+ var w=Object.defineProperty;var f=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var g=(n,e,t)=>e in n?w(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t,y=(n,e)=>{for(var t in e||(e={}))h.call(e,t)&&g(n,t,e[t]);if(f)for(var t of f(e))O.call(e,t)&&g(n,t,e[t]);return n};var o=(n,e,t)=>new Promise((u,r)=>{var d=i=>{try{p(t.next(i));}catch(l){r(l);}},s=i=>{try{p(t.throw(i));}catch(l){r(l);}},p=i=>i.done?u(i.value):Promise.resolve(i.value).then(d,s);p((t=t.apply(n,e)).next());});var a={name:"@tikkhun/index-generator",version:"0.0.3",description:""};var m={cwd:".",indexName:"index.ts",include:"*",exclude:[]};function k(n){return o(this,null,function*(){try{let e=mergeOptions(m,n),t=c.resolve(e.cwd),r=(yield glob(e.include,{cwd:t,ignore:e.exclude})).map(s=>`export * from "./${c.extname(s)?c.basename(s).split(c.extname(s))[0]:s}";`).join(`
5
+ `);console.log(r);let d=(e==null?void 0:e.indexName)||"index.ts";if(yield G(d)){console.error("index.ts \u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA");return}yield x.writeFile(d,r,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function G(n){return o(this,null,function*(){try{return yield x.access(n,x.constants.F_OK),!0}catch(e){return false}})}var D=y({},m),F={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664"},N={cwd:"string",indexName:"string",include:"array",exclude:"array"},T={name:a.name,version:a.version,description:a.description,types:[CommandTypes.args,CommandTypes.prompts],defaultOptions:D,optionTitles:F,optionTypes:N,action:n=>o(null,null,function*(){k(n);})},B=new Cli(T);export{B as cli,T as cliOptions,D as defaultOptions,F as optionTitles,N as optionTypes};
@@ -1,6 +1,14 @@
1
- interface GenerateIndexOptions {
1
+ declare const DefaultGenerateIndexOptions: {
2
+ cwd: string;
2
3
  indexName: string;
3
- }
4
- declare function generateIndex(path: string, options?: Partial<GenerateIndexOptions>): Promise<void>;
4
+ include: string;
5
+ exclude: never[];
6
+ };
7
+ type GenerateIndexOptions = typeof DefaultGenerateIndexOptions & {
8
+ include: string | string[];
9
+ exclude: string[];
10
+ };
11
+ declare function generateIndex(options?: Partial<GenerateIndexOptions>): Promise<void>;
12
+ declare function isFileExists(filePath: string): Promise<boolean>;
5
13
 
6
- export { generateIndex };
14
+ export { DefaultGenerateIndexOptions, generateIndex, isFileExists };
@@ -1,6 +1,14 @@
1
- interface GenerateIndexOptions {
1
+ declare const DefaultGenerateIndexOptions: {
2
+ cwd: string;
2
3
  indexName: string;
3
- }
4
- declare function generateIndex(path: string, options?: Partial<GenerateIndexOptions>): Promise<void>;
4
+ include: string;
5
+ exclude: never[];
6
+ };
7
+ type GenerateIndexOptions = typeof DefaultGenerateIndexOptions & {
8
+ include: string | string[];
9
+ exclude: string[];
10
+ };
11
+ declare function generateIndex(options?: Partial<GenerateIndexOptions>): Promise<void>;
12
+ declare function isFileExists(filePath: string): Promise<boolean>;
5
13
 
6
- export { generateIndex };
14
+ export { DefaultGenerateIndexOptions, generateIndex, isFileExists };
package/dist/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
- 'use strict';var glob=require('glob'),d=require('fs/promises');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var d__default=/*#__PURE__*/_interopDefault(d);/**
2
- index-generator
1
+ 'use strict';var utilsCore=require('@tikkhun/utils-core'),l=require('fs/promises'),glob=require('glob'),a=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var l__default=/*#__PURE__*/_interopDefault(l);var a__default=/*#__PURE__*/_interopDefault(a);/**
2
+ @tikkhun/index-generator
3
3
  */
4
- var f=(a,t,e)=>new Promise((i,n)=>{var m=r=>{try{o(e.next(r));}catch(x){n(x);}},s=r=>{try{o(e.throw(r));}catch(x){n(x);}},o=r=>r.done?i(r.value):Promise.resolve(r.value).then(m,s);o((e=e.apply(a,t)).next());});function w(a,t){return f(this,null,function*(){try{let i=(yield glob.glob(a)).map(n=>`export * from "${n}";`).join(`
5
- `);yield d__default.default.writeFile((t==null?void 0:t.indexName)||"index.ts",i,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}exports.generateIndex=w;
4
+ var d=(o,e,n)=>new Promise((p,s)=>{var i=t=>{try{c(n.next(t));}catch(x){s(x);}},r=t=>{try{c(n.throw(t));}catch(x){s(x);}},c=t=>t.done?p(t.value):Promise.resolve(t.value).then(i,r);c((n=n.apply(o,e)).next());});var f={cwd:".",indexName:"index.ts",include:"*",exclude:[]};function F(o){return d(this,null,function*(){try{let e=utilsCore.mergeOptions(f,o),n=a__default.default.resolve(e.cwd),s=(yield glob.glob(e.include,{cwd:n,ignore:e.exclude})).map(r=>`export * from "./${a__default.default.extname(r)?a__default.default.basename(r).split(a__default.default.extname(r))[0]:r}";`).join(`
5
+ `);console.log(s);let i=(e==null?void 0:e.indexName)||"index.ts";if(yield g(i)){console.error("index.ts \u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA");return}yield l__default.default.writeFile(i,s,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function g(o){return d(this,null,function*(){try{return yield l__default.default.access(o,l__default.default.constants.F_OK),!0}catch(e){return false}})}exports.DefaultGenerateIndexOptions=f;exports.generateIndex=F;exports.isFileExists=g;
@@ -1,5 +1,5 @@
1
- import {glob}from'glob';import d from'fs/promises';/**
2
- index-generator
1
+ import {mergeOptions}from'@tikkhun/utils-core';import l from'fs/promises';import {glob}from'glob';import a from'path';/**
2
+ @tikkhun/index-generator
3
3
  */
4
- var f=(a,t,e)=>new Promise((i,n)=>{var m=r=>{try{o(e.next(r));}catch(x){n(x);}},s=r=>{try{o(e.throw(r));}catch(x){n(x);}},o=r=>r.done?i(r.value):Promise.resolve(r.value).then(m,s);o((e=e.apply(a,t)).next());});function w(a,t){return f(this,null,function*(){try{let i=(yield glob(a)).map(n=>`export * from "${n}";`).join(`
5
- `);yield d.writeFile((t==null?void 0:t.indexName)||"index.ts",i,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}export{w as generateIndex};
4
+ var d=(o,e,n)=>new Promise((p,s)=>{var i=t=>{try{c(n.next(t));}catch(x){s(x);}},r=t=>{try{c(n.throw(t));}catch(x){s(x);}},c=t=>t.done?p(t.value):Promise.resolve(t.value).then(i,r);c((n=n.apply(o,e)).next());});var f={cwd:".",indexName:"index.ts",include:"*",exclude:[]};function F(o){return d(this,null,function*(){try{let e=mergeOptions(f,o),n=a.resolve(e.cwd),s=(yield glob(e.include,{cwd:n,ignore:e.exclude})).map(r=>`export * from "./${a.extname(r)?a.basename(r).split(a.extname(r))[0]:r}";`).join(`
5
+ `);console.log(s);let i=(e==null?void 0:e.indexName)||"index.ts";if(yield g(i)){console.error("index.ts \u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA");return}yield l.writeFile(i,s,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function g(o){return d(this,null,function*(){try{return yield l.access(o,l.constants.F_OK),!0}catch(e){return false}})}export{f as DefaultGenerateIndexOptions,F as generateIndex,g as isFileExists};
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@tikkhun/index-generator",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
5
  "bin": {
6
- "tikkhun-index-generator": "dist/cli/cli.js"
6
+ "tikkhun-index-generator": "dist/cli/index.js"
7
7
  },
8
8
  "main": "dist/lib/index.js",
9
9
  "module": "dist/lib/index.mjs",
@@ -30,10 +30,12 @@
30
30
  "author": "",
31
31
  "license": "ISC",
32
32
  "dependencies": {
33
- "@tikkhun/cli-core": "latest",
34
33
  "@tikkhun/logger": "latest",
34
+ "@tikkhun/overload": "^0.0.1",
35
35
  "commander": "^12.1.0",
36
- "glob": "^11.0.2"
36
+ "glob": "^11.0.2",
37
+ "@tikkhun/utils-core": "0.0.19",
38
+ "@tikkhun/cli-core": "0.0.21"
37
39
  },
38
40
  "devDependencies": {
39
41
  "@types/node": "^20.3.1",