@tikkhun/index-generator 0.0.6 → 0.1.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/dist/cli/index.js +3 -3
- package/dist/cli/index.mjs +3 -3
- package/dist/lib/cli/index.d.mts +10 -2
- package/dist/lib/cli/index.d.ts +10 -2
- package/dist/lib/cli/index.js +3 -3
- package/dist/lib/cli/index.mjs +3 -3
- package/dist/lib/index.d.mts +3 -1
- package/dist/lib/index.d.ts +3 -1
- package/dist/lib/index.js +3 -3
- package/dist/lib/index.mjs +3 -3
- package/package.json +6 -6
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'),utilsCore=require('@tikkhun/utils-core'),
|
2
|
+
'use strict';var cliCore=require('@tikkhun/cli-core'),utilsCore=require('@tikkhun/utils-core'),fs=require('fs'),promises=require('fs/promises'),glob=require('glob'),o=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var o__default=/*#__PURE__*/_interopDefault(o);/**
|
3
3
|
@tikkhun/index-generator
|
4
4
|
*/
|
5
|
-
var
|
6
|
-
`);console.log(r);let
|
5
|
+
var O=Object.defineProperty,j=Object.defineProperties;var v=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var b=(i,e,t)=>e in i?O(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,p=(i,e)=>{for(var t in e||(e={}))I.call(e,t)&&b(i,t,e[t]);if(y)for(var t of y(e))G.call(e,t)&&b(i,t,e[t]);return i},x=(i,e)=>j(i,v(e));var d=(i,e,t)=>new Promise((g,r)=>{var c=n=>{try{a(t.next(n));}catch(l){r(l);}},s=n=>{try{a(t.throw(n));}catch(l){r(l);}},a=n=>n.done?g(n.value):Promise.resolve(n.value).then(c,s);a((t=t.apply(i,e)).next());});var u={name:"@tikkhun/index-generator",version:"0.1.0",description:""};var m={cwd:".",indexName:"index.ts",include:["*"],exclude:[],clean:false,child:false,debug:false};function f(i){return d(this,null,function*(){try{let e=utilsCore.mergeOptions(m,i);e.debug&&console.log("opts",e);let t=o__default.default.resolve(e.cwd);if(e.child){let a=(yield glob.glob("**/*",{cwd:t,ignore:e.exclude})).filter(n=>fs.statSync(o__default.default.join(t,n)).isDirectory());for(let n of a)console.log("\u5BF9\u76EE\u5F55\u8FDB\u884Cindex\u751F\u6210",n),yield f(x(p({},e),{cwd:o__default.default.join(t,n),child:!1}));return}let r=(yield glob.glob(e.include,{cwd:t,ignore:e.exclude})).map(s=>`export * from "./${o__default.default.extname(s)?o__default.default.basename(s).split(o__default.default.extname(s))[0]:s}";`).join(`
|
6
|
+
`);console.log(r);let c=o__default.default.join(t,e.indexName);if(!(e!=null&&e.clean)&&(yield E(c))){console.error(`index\u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA,\u6587\u4EF6\u540D\u4E3A${c}`);return}yield promises.writeFile(c,r,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function E(i){return d(this,null,function*(){try{return yield promises.access(i,promises.constants.F_OK),!0}catch(e){return false}})}var q=x(p({},m),{child:false}),J={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664",clean:"\u6E05\u9664\u65E7\u7684",child:"\u5B50\u76EE\u5F55"},K={cwd:"string",indexName:"string",include:"array",exclude:"array",clean:"boolean",child:"boolean"},P={name:u.name,version:u.version,description:u.description,types:[cliCore.CommandTypes.args,cliCore.CommandTypes.prompts],defaultOptions:q,optionTitles:J,optionTypes:K,action:i=>d(null,null,function*(){f(i);})},k=new cliCore.Cli(P);k.start();
|
package/dist/cli/index.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
import {CommandTypes,Cli}from'@tikkhun/cli-core';import {mergeOptions}from'@tikkhun/utils-core';import
|
2
|
+
import {CommandTypes,Cli}from'@tikkhun/cli-core';import {mergeOptions}from'@tikkhun/utils-core';import {statSync}from'fs';import {writeFile,access,constants}from'fs/promises';import {glob}from'glob';import o from'path';/**
|
3
3
|
@tikkhun/index-generator
|
4
4
|
*/
|
5
|
-
var
|
6
|
-
`);console.log(r);let
|
5
|
+
var O=Object.defineProperty,j=Object.defineProperties;var v=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var b=(i,e,t)=>e in i?O(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,p=(i,e)=>{for(var t in e||(e={}))I.call(e,t)&&b(i,t,e[t]);if(y)for(var t of y(e))G.call(e,t)&&b(i,t,e[t]);return i},x=(i,e)=>j(i,v(e));var d=(i,e,t)=>new Promise((g,r)=>{var c=n=>{try{a(t.next(n));}catch(l){r(l);}},s=n=>{try{a(t.throw(n));}catch(l){r(l);}},a=n=>n.done?g(n.value):Promise.resolve(n.value).then(c,s);a((t=t.apply(i,e)).next());});var u={name:"@tikkhun/index-generator",version:"0.1.0",description:""};var m={cwd:".",indexName:"index.ts",include:["*"],exclude:[],clean:false,child:false,debug:false};function f(i){return d(this,null,function*(){try{let e=mergeOptions(m,i);e.debug&&console.log("opts",e);let t=o.resolve(e.cwd);if(e.child){let a=(yield glob("**/*",{cwd:t,ignore:e.exclude})).filter(n=>statSync(o.join(t,n)).isDirectory());for(let n of a)console.log("\u5BF9\u76EE\u5F55\u8FDB\u884Cindex\u751F\u6210",n),yield f(x(p({},e),{cwd:o.join(t,n),child:!1}));return}let r=(yield glob(e.include,{cwd:t,ignore:e.exclude})).map(s=>`export * from "./${o.extname(s)?o.basename(s).split(o.extname(s))[0]:s}";`).join(`
|
6
|
+
`);console.log(r);let c=o.join(t,e.indexName);if(!(e!=null&&e.clean)&&(yield E(c))){console.error(`index\u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA,\u6587\u4EF6\u540D\u4E3A${c}`);return}yield writeFile(c,r,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function E(i){return d(this,null,function*(){try{return yield access(i,constants.F_OK),!0}catch(e){return false}})}var q=x(p({},m),{child:false}),J={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664",clean:"\u6E05\u9664\u65E7\u7684",child:"\u5B50\u76EE\u5F55"},K={cwd:"string",indexName:"string",include:"array",exclude:"array",clean:"boolean",child:"boolean"},P={name:u.name,version:u.version,description:u.description,types:[CommandTypes.args,CommandTypes.prompts],defaultOptions:q,optionTitles:J,optionTypes:K,action:i=>d(null,null,function*(){f(i);})},k=new Cli(P);k.start();
|
package/dist/lib/cli/index.d.mts
CHANGED
@@ -2,11 +2,13 @@ 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
|
+
child: boolean;
|
5
6
|
cwd: string;
|
6
7
|
indexName: string;
|
7
|
-
include: string;
|
8
|
+
include: string[];
|
8
9
|
exclude: never[];
|
9
10
|
clean: boolean;
|
11
|
+
debug: boolean;
|
10
12
|
};
|
11
13
|
declare const optionTitles: {
|
12
14
|
cwd: string;
|
@@ -14,6 +16,7 @@ declare const optionTitles: {
|
|
14
16
|
include: string;
|
15
17
|
exclude: string;
|
16
18
|
clean: string;
|
19
|
+
child: string;
|
17
20
|
};
|
18
21
|
declare const optionTypes: {
|
19
22
|
cwd: string;
|
@@ -21,6 +24,7 @@ declare const optionTypes: {
|
|
21
24
|
include: string;
|
22
25
|
exclude: string;
|
23
26
|
clean: string;
|
27
|
+
child: string;
|
24
28
|
};
|
25
29
|
declare const cliOptions: {
|
26
30
|
name: string;
|
@@ -28,11 +32,13 @@ declare const cliOptions: {
|
|
28
32
|
description: string;
|
29
33
|
types: CommandTypes[];
|
30
34
|
defaultOptions: {
|
35
|
+
child: boolean;
|
31
36
|
cwd: string;
|
32
37
|
indexName: string;
|
33
|
-
include: string;
|
38
|
+
include: string[];
|
34
39
|
exclude: never[];
|
35
40
|
clean: boolean;
|
41
|
+
debug: boolean;
|
36
42
|
};
|
37
43
|
optionTitles: {
|
38
44
|
cwd: string;
|
@@ -40,6 +46,7 @@ declare const cliOptions: {
|
|
40
46
|
include: string;
|
41
47
|
exclude: string;
|
42
48
|
clean: string;
|
49
|
+
child: string;
|
43
50
|
};
|
44
51
|
optionTypes: {
|
45
52
|
cwd: string;
|
@@ -47,6 +54,7 @@ declare const cliOptions: {
|
|
47
54
|
include: string;
|
48
55
|
exclude: string;
|
49
56
|
clean: string;
|
57
|
+
child: string;
|
50
58
|
};
|
51
59
|
action: (options: any) => Promise<void>;
|
52
60
|
};
|
package/dist/lib/cli/index.d.ts
CHANGED
@@ -2,11 +2,13 @@ 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
|
+
child: boolean;
|
5
6
|
cwd: string;
|
6
7
|
indexName: string;
|
7
|
-
include: string;
|
8
|
+
include: string[];
|
8
9
|
exclude: never[];
|
9
10
|
clean: boolean;
|
11
|
+
debug: boolean;
|
10
12
|
};
|
11
13
|
declare const optionTitles: {
|
12
14
|
cwd: string;
|
@@ -14,6 +16,7 @@ declare const optionTitles: {
|
|
14
16
|
include: string;
|
15
17
|
exclude: string;
|
16
18
|
clean: string;
|
19
|
+
child: string;
|
17
20
|
};
|
18
21
|
declare const optionTypes: {
|
19
22
|
cwd: string;
|
@@ -21,6 +24,7 @@ declare const optionTypes: {
|
|
21
24
|
include: string;
|
22
25
|
exclude: string;
|
23
26
|
clean: string;
|
27
|
+
child: string;
|
24
28
|
};
|
25
29
|
declare const cliOptions: {
|
26
30
|
name: string;
|
@@ -28,11 +32,13 @@ declare const cliOptions: {
|
|
28
32
|
description: string;
|
29
33
|
types: CommandTypes[];
|
30
34
|
defaultOptions: {
|
35
|
+
child: boolean;
|
31
36
|
cwd: string;
|
32
37
|
indexName: string;
|
33
|
-
include: string;
|
38
|
+
include: string[];
|
34
39
|
exclude: never[];
|
35
40
|
clean: boolean;
|
41
|
+
debug: boolean;
|
36
42
|
};
|
37
43
|
optionTitles: {
|
38
44
|
cwd: string;
|
@@ -40,6 +46,7 @@ declare const cliOptions: {
|
|
40
46
|
include: string;
|
41
47
|
exclude: string;
|
42
48
|
clean: string;
|
49
|
+
child: string;
|
43
50
|
};
|
44
51
|
optionTypes: {
|
45
52
|
cwd: string;
|
@@ -47,6 +54,7 @@ declare const cliOptions: {
|
|
47
54
|
include: string;
|
48
55
|
exclude: string;
|
49
56
|
clean: string;
|
57
|
+
child: string;
|
50
58
|
};
|
51
59
|
action: (options: any) => Promise<void>;
|
52
60
|
};
|
package/dist/lib/cli/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
'use strict';var cliCore=require('@tikkhun/cli-core'),utilsCore=require('@tikkhun/utils-core'),
|
1
|
+
'use strict';var cliCore=require('@tikkhun/cli-core'),utilsCore=require('@tikkhun/utils-core'),fs=require('fs'),promises=require('fs/promises'),glob=require('glob'),o=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var o__default=/*#__PURE__*/_interopDefault(o);/**
|
2
2
|
@tikkhun/index-generator
|
3
3
|
*/
|
4
|
-
var
|
5
|
-
`);console.log(r);let
|
4
|
+
var k=Object.defineProperty,O=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var b=(i,e,t)=>e in i?k(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,p=(i,e)=>{for(var t in e||(e={}))I.call(e,t)&&b(i,t,e[t]);if(y)for(var t of y(e))v.call(e,t)&&b(i,t,e[t]);return i},x=(i,e)=>O(i,j(e));var d=(i,e,t)=>new Promise((g,r)=>{var c=n=>{try{a(t.next(n));}catch(l){r(l);}},s=n=>{try{a(t.throw(n));}catch(l){r(l);}},a=n=>n.done?g(n.value):Promise.resolve(n.value).then(c,s);a((t=t.apply(i,e)).next());});var u={name:"@tikkhun/index-generator",version:"0.1.0",description:""};var m={cwd:".",indexName:"index.ts",include:["*"],exclude:[],clean:false,child:false,debug:false};function f(i){return d(this,null,function*(){try{let e=utilsCore.mergeOptions(m,i);e.debug&&console.log("opts",e);let t=o__default.default.resolve(e.cwd);if(e.child){let a=(yield glob.glob("**/*",{cwd:t,ignore:e.exclude})).filter(n=>fs.statSync(o__default.default.join(t,n)).isDirectory());for(let n of a)console.log("\u5BF9\u76EE\u5F55\u8FDB\u884Cindex\u751F\u6210",n),yield f(x(p({},e),{cwd:o__default.default.join(t,n),child:!1}));return}let r=(yield glob.glob(e.include,{cwd:t,ignore:e.exclude})).map(s=>`export * from "./${o__default.default.extname(s)?o__default.default.basename(s).split(o__default.default.extname(s))[0]:s}";`).join(`
|
5
|
+
`);console.log(r);let c=o__default.default.join(t,e.indexName);if(!(e!=null&&e.clean)&&(yield T(c))){console.error(`index\u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA,\u6587\u4EF6\u540D\u4E3A${c}`);return}yield promises.writeFile(c,r,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function T(i){return d(this,null,function*(){try{return yield promises.access(i,promises.constants.F_OK),!0}catch(e){return false}})}var $=x(p({},m),{child:false}),q={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664",clean:"\u6E05\u9664\u65E7\u7684",child:"\u5B50\u76EE\u5F55"},J={cwd:"string",indexName:"string",include:"array",exclude:"array",clean:"boolean",child:"boolean"},K={name:u.name,version:u.version,description:u.description,types:[cliCore.CommandTypes.args,cliCore.CommandTypes.prompts],defaultOptions:$,optionTitles:q,optionTypes:J,action:i=>d(null,null,function*(){f(i);})},V=new cliCore.Cli(K);exports.cli=V;exports.cliOptions=K;exports.defaultOptions=$;exports.optionTitles=q;exports.optionTypes=J;
|
package/dist/lib/cli/index.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import {CommandTypes,Cli}from'@tikkhun/cli-core';import {mergeOptions}from'@tikkhun/utils-core';import
|
1
|
+
import {CommandTypes,Cli}from'@tikkhun/cli-core';import {mergeOptions}from'@tikkhun/utils-core';import {statSync}from'fs';import {writeFile,access,constants}from'fs/promises';import {glob}from'glob';import o from'path';/**
|
2
2
|
@tikkhun/index-generator
|
3
3
|
*/
|
4
|
-
var
|
5
|
-
`);console.log(r);let
|
4
|
+
var k=Object.defineProperty,O=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var b=(i,e,t)=>e in i?k(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,p=(i,e)=>{for(var t in e||(e={}))I.call(e,t)&&b(i,t,e[t]);if(y)for(var t of y(e))v.call(e,t)&&b(i,t,e[t]);return i},x=(i,e)=>O(i,j(e));var d=(i,e,t)=>new Promise((g,r)=>{var c=n=>{try{a(t.next(n));}catch(l){r(l);}},s=n=>{try{a(t.throw(n));}catch(l){r(l);}},a=n=>n.done?g(n.value):Promise.resolve(n.value).then(c,s);a((t=t.apply(i,e)).next());});var u={name:"@tikkhun/index-generator",version:"0.1.0",description:""};var m={cwd:".",indexName:"index.ts",include:["*"],exclude:[],clean:false,child:false,debug:false};function f(i){return d(this,null,function*(){try{let e=mergeOptions(m,i);e.debug&&console.log("opts",e);let t=o.resolve(e.cwd);if(e.child){let a=(yield glob("**/*",{cwd:t,ignore:e.exclude})).filter(n=>statSync(o.join(t,n)).isDirectory());for(let n of a)console.log("\u5BF9\u76EE\u5F55\u8FDB\u884Cindex\u751F\u6210",n),yield f(x(p({},e),{cwd:o.join(t,n),child:!1}));return}let r=(yield glob(e.include,{cwd:t,ignore:e.exclude})).map(s=>`export * from "./${o.extname(s)?o.basename(s).split(o.extname(s))[0]:s}";`).join(`
|
5
|
+
`);console.log(r);let c=o.join(t,e.indexName);if(!(e!=null&&e.clean)&&(yield T(c))){console.error(`index\u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA,\u6587\u4EF6\u540D\u4E3A${c}`);return}yield writeFile(c,r,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function T(i){return d(this,null,function*(){try{return yield access(i,constants.F_OK),!0}catch(e){return false}})}var $=x(p({},m),{child:false}),q={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664",clean:"\u6E05\u9664\u65E7\u7684",child:"\u5B50\u76EE\u5F55"},J={cwd:"string",indexName:"string",include:"array",exclude:"array",clean:"boolean",child:"boolean"},K={name:u.name,version:u.version,description:u.description,types:[CommandTypes.args,CommandTypes.prompts],defaultOptions:$,optionTitles:q,optionTypes:J,action:i=>d(null,null,function*(){f(i);})},V=new Cli(K);export{V as cli,K as cliOptions,$ as defaultOptions,q as optionTitles,J as optionTypes};
|
package/dist/lib/index.d.mts
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
declare const DefaultGenerateIndexOptions: {
|
2
2
|
cwd: string;
|
3
3
|
indexName: string;
|
4
|
-
include: string;
|
4
|
+
include: string[];
|
5
5
|
exclude: never[];
|
6
6
|
clean: boolean;
|
7
|
+
child: boolean;
|
8
|
+
debug: boolean;
|
7
9
|
};
|
8
10
|
type GenerateIndexOptions = typeof DefaultGenerateIndexOptions & {
|
9
11
|
include: string | string[];
|
package/dist/lib/index.d.ts
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
declare const DefaultGenerateIndexOptions: {
|
2
2
|
cwd: string;
|
3
3
|
indexName: string;
|
4
|
-
include: string;
|
4
|
+
include: string[];
|
5
5
|
exclude: never[];
|
6
6
|
clean: boolean;
|
7
|
+
child: boolean;
|
8
|
+
debug: boolean;
|
7
9
|
};
|
8
10
|
type GenerateIndexOptions = typeof DefaultGenerateIndexOptions & {
|
9
11
|
include: string | string[];
|
package/dist/lib/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
'use strict';var utilsCore=require('@tikkhun/utils-core'),
|
1
|
+
'use strict';var utilsCore=require('@tikkhun/utils-core'),fs=require('fs'),promises=require('fs/promises'),glob=require('glob'),i=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var i__default=/*#__PURE__*/_interopDefault(i);/**
|
2
2
|
@tikkhun/index-generator
|
3
3
|
*/
|
4
|
-
var
|
5
|
-
`);console.log(
|
4
|
+
var w=Object.defineProperty,y=Object.defineProperties;var O=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var p=(n,e,t)=>e in n?w(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t,u=(n,e)=>{for(var t in e||(e={}))h.call(e,t)&&p(n,t,e[t]);if(x)for(var t of x(e))I.call(e,t)&&p(n,t,e[t]);return n},m=(n,e)=>y(n,O(e));var d=(n,e,t)=>new Promise((f,s)=>{var a=o=>{try{c(t.next(o));}catch(l){s(l);}},r=o=>{try{c(t.throw(o));}catch(l){s(l);}},c=o=>o.done?f(o.value):Promise.resolve(o.value).then(a,r);c((t=t.apply(n,e)).next());});var D={cwd:".",indexName:"index.ts",include:["*"],exclude:[],clean:false,child:false,debug:false};function E(n){return d(this,null,function*(){try{let e=utilsCore.mergeOptions(D,n);e.debug&&console.log("opts",e);let t=i__default.default.resolve(e.cwd);if(e.child){let c=(yield glob.glob("**/*",{cwd:t,ignore:e.exclude})).filter(o=>fs.statSync(i__default.default.join(t,o)).isDirectory());for(let o of c)console.log("\u5BF9\u76EE\u5F55\u8FDB\u884Cindex\u751F\u6210",o),yield E(m(u({},e),{cwd:i__default.default.join(t,o),child:!1}));return}let s=(yield glob.glob(e.include,{cwd:t,ignore:e.exclude})).map(r=>`export * from "./${i__default.default.extname(r)?i__default.default.basename(r).split(i__default.default.extname(r))[0]:r}";`).join(`
|
5
|
+
`);console.log(s);let a=i__default.default.join(t,e.indexName);if(!(e!=null&&e.clean)&&(yield N(a))){console.error(`index\u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA,\u6587\u4EF6\u540D\u4E3A${a}`);return}yield promises.writeFile(a,s,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function N(n){return d(this,null,function*(){try{return yield promises.access(n,promises.constants.F_OK),!0}catch(e){return false}})}exports.DefaultGenerateIndexOptions=D;exports.generateIndex=E;exports.isFileExists=N;
|
package/dist/lib/index.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import {mergeOptions}from'@tikkhun/utils-core';import
|
1
|
+
import {mergeOptions}from'@tikkhun/utils-core';import {statSync}from'fs';import {writeFile,access,constants}from'fs/promises';import {glob}from'glob';import i from'path';/**
|
2
2
|
@tikkhun/index-generator
|
3
3
|
*/
|
4
|
-
var
|
5
|
-
`);console.log(
|
4
|
+
var w=Object.defineProperty,y=Object.defineProperties;var O=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var p=(n,e,t)=>e in n?w(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t,u=(n,e)=>{for(var t in e||(e={}))h.call(e,t)&&p(n,t,e[t]);if(x)for(var t of x(e))I.call(e,t)&&p(n,t,e[t]);return n},m=(n,e)=>y(n,O(e));var d=(n,e,t)=>new Promise((f,s)=>{var a=o=>{try{c(t.next(o));}catch(l){s(l);}},r=o=>{try{c(t.throw(o));}catch(l){s(l);}},c=o=>o.done?f(o.value):Promise.resolve(o.value).then(a,r);c((t=t.apply(n,e)).next());});var D={cwd:".",indexName:"index.ts",include:["*"],exclude:[],clean:false,child:false,debug:false};function E(n){return d(this,null,function*(){try{let e=mergeOptions(D,n);e.debug&&console.log("opts",e);let t=i.resolve(e.cwd);if(e.child){let c=(yield glob("**/*",{cwd:t,ignore:e.exclude})).filter(o=>statSync(i.join(t,o)).isDirectory());for(let o of c)console.log("\u5BF9\u76EE\u5F55\u8FDB\u884Cindex\u751F\u6210",o),yield E(m(u({},e),{cwd:i.join(t,o),child:!1}));return}let s=(yield glob(e.include,{cwd:t,ignore:e.exclude})).map(r=>`export * from "./${i.extname(r)?i.basename(r).split(i.extname(r))[0]:r}";`).join(`
|
5
|
+
`);console.log(s);let a=i.join(t,e.indexName);if(!(e!=null&&e.clean)&&(yield N(a))){console.error(`index\u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA,\u6587\u4EF6\u540D\u4E3A${a}`);return}yield writeFile(a,s,"utf-8");}catch(e){console.error("\u751F\u6210 index \u6587\u4EF6\u65F6\u51FA\u9519:",e);}})}function N(n){return d(this,null,function*(){try{return yield access(n,constants.F_OK),!0}catch(e){return false}})}export{D as DefaultGenerateIndexOptions,E as generateIndex,N as isFileExists};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tikkhun/index-generator",
|
3
|
-
"version": "0.0
|
3
|
+
"version": "0.1.0",
|
4
4
|
"description": "",
|
5
5
|
"bin": {
|
6
6
|
"tikkhun-index-generator": "dist/cli/index.js"
|
@@ -30,16 +30,16 @@
|
|
30
30
|
"author": "",
|
31
31
|
"license": "ISC",
|
32
32
|
"dependencies": {
|
33
|
-
"glob": "^11.0.
|
33
|
+
"glob": "^11.0.3",
|
34
34
|
"@tikkhun/cli-core": "^0.0.28",
|
35
|
-
"@tikkhun/
|
36
|
-
"@tikkhun/
|
35
|
+
"@tikkhun/logger": "^1.0.8",
|
36
|
+
"@tikkhun/utils-core": "^0.0.22"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
39
|
"@types/node": "^20.3.1",
|
40
40
|
"tsup": "^8.5.0",
|
41
|
-
"tsx": "^4.20.
|
42
|
-
"vitest": "^3.2.
|
41
|
+
"tsx": "^4.20.3",
|
42
|
+
"vitest": "^3.2.4"
|
43
43
|
},
|
44
44
|
"scripts": {
|
45
45
|
"build": "tsup",
|