@tikkhun/index-generator 0.0.6 → 0.1.1
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 +14 -2
- package/dist/lib/cli/index.d.ts +14 -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 a=(e
|
5
|
+
var O=Object.defineProperty,j=Object.defineProperties;var v=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var y=(i,e,t)=>e in i?O(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,x=(i,e)=>{for(var t in e||(e={}))I.call(e,t)&&y(i,t,e[t]);if(b)for(var t of b(e))G.call(e,t)&&y(i,t,e[t]);return i},u=(i,e)=>j(i,v(e));var d=(i,e,t)=>new Promise((g,r)=>{var a=n=>{try{c(t.next(n));}catch(p){r(p);}},s=n=>{try{c(t.throw(n));}catch(p){r(p);}},c=n=>n.done?g(n.value):Promise.resolve(n.value).then(a,s);c((t=t.apply(i,e)).next());});var l={name:"@tikkhun/index-generator",version:"0.1.1",description:"",bin:{"tikkhun-index-generator":"dist/cli/index.js"},main:"dist/lib/index.js",module:"dist/lib/index.mjs",types:"dist/lib/index.d.ts",exports:{".":{import:{types:"./dist/lib/index.d.mts",default:"./dist/lib/index.mjs"},require:{types:"./dist/lib/index.d.ts",default:"./dist/lib/index.js"}}},files:["dist"],scripts:{build:"tsup",dev:"tsx ./src/index.ts",test:"vitest"},publishConfig:{access:"public"},keywords:[],author:"",license:"ISC",dependencies:{"@tikkhun/cli-core":"workspace:^","@tikkhun/logger":"workspace:^","@tikkhun/utils-core":"workspace:^",glob:"^11.0.3"},devDependencies:{"@types/node":"^20.3.1",tsup:"^8.5.0",tsx:"^4.20.3",vitest:"^3.2.4"}};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 c=(yield glob.glob("**/*",{cwd:t,ignore:e.exclude})).filter(n=>fs.statSync(o__default.default.join(t,n)).isDirectory());for(let n of c)console.log("\u5BF9\u76EE\u5F55\u8FDB\u884Cindex\u751F\u6210",n),yield f(u(x({},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 a=o__default.default.join(t,e.indexName);if(!(e!=null&&e.clean)&&(yield E(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,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=u(x({},m),{child:false});cliCore.echoPackage(l);var J={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664",clean:"\u6E05\u9664\u65E7\u7684",child:"\u5B50\u76EE\u5F55",debug:"\u8C03\u8BD5"},K={cwd:"string",indexName:"string",include:"array",exclude:"array",clean:"boolean",child:"boolean",debug:"boolean"},W={name:l.name,version:l.version,description:l.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(W);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 {echoPackage,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 a=(e
|
5
|
+
var O=Object.defineProperty,j=Object.defineProperties;var v=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var y=(i,e,t)=>e in i?O(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,x=(i,e)=>{for(var t in e||(e={}))I.call(e,t)&&y(i,t,e[t]);if(b)for(var t of b(e))G.call(e,t)&&y(i,t,e[t]);return i},u=(i,e)=>j(i,v(e));var d=(i,e,t)=>new Promise((g,r)=>{var a=n=>{try{c(t.next(n));}catch(p){r(p);}},s=n=>{try{c(t.throw(n));}catch(p){r(p);}},c=n=>n.done?g(n.value):Promise.resolve(n.value).then(a,s);c((t=t.apply(i,e)).next());});var l={name:"@tikkhun/index-generator",version:"0.1.1",description:"",bin:{"tikkhun-index-generator":"dist/cli/index.js"},main:"dist/lib/index.js",module:"dist/lib/index.mjs",types:"dist/lib/index.d.ts",exports:{".":{import:{types:"./dist/lib/index.d.mts",default:"./dist/lib/index.mjs"},require:{types:"./dist/lib/index.d.ts",default:"./dist/lib/index.js"}}},files:["dist"],scripts:{build:"tsup",dev:"tsx ./src/index.ts",test:"vitest"},publishConfig:{access:"public"},keywords:[],author:"",license:"ISC",dependencies:{"@tikkhun/cli-core":"workspace:^","@tikkhun/logger":"workspace:^","@tikkhun/utils-core":"workspace:^",glob:"^11.0.3"},devDependencies:{"@types/node":"^20.3.1",tsup:"^8.5.0",tsx:"^4.20.3",vitest:"^3.2.4"}};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 c=(yield glob("**/*",{cwd:t,ignore:e.exclude})).filter(n=>statSync(o.join(t,n)).isDirectory());for(let n of c)console.log("\u5BF9\u76EE\u5F55\u8FDB\u884Cindex\u751F\u6210",n),yield f(u(x({},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 a=o.join(t,e.indexName);if(!(e!=null&&e.clean)&&(yield E(a))){console.error(`index\u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA,\u6587\u4EF6\u540D\u4E3A${a}`);return}yield writeFile(a,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=u(x({},m),{child:false});echoPackage(l);var J={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664",clean:"\u6E05\u9664\u65E7\u7684",child:"\u5B50\u76EE\u5F55",debug:"\u8C03\u8BD5"},K={cwd:"string",indexName:"string",include:"array",exclude:"array",clean:"boolean",child:"boolean",debug:"boolean"},W={name:l.name,version:l.version,description:l.description,types:[CommandTypes.args,CommandTypes.prompts],defaultOptions:q,optionTitles:J,optionTypes:K,action:i=>d(null,null,function*(){f(i);})},k=new Cli(W);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,8 @@ declare const optionTitles: {
|
|
14
16
|
include: string;
|
15
17
|
exclude: string;
|
16
18
|
clean: string;
|
19
|
+
child: string;
|
20
|
+
debug: string;
|
17
21
|
};
|
18
22
|
declare const optionTypes: {
|
19
23
|
cwd: string;
|
@@ -21,6 +25,8 @@ declare const optionTypes: {
|
|
21
25
|
include: string;
|
22
26
|
exclude: string;
|
23
27
|
clean: string;
|
28
|
+
child: string;
|
29
|
+
debug: string;
|
24
30
|
};
|
25
31
|
declare const cliOptions: {
|
26
32
|
name: string;
|
@@ -28,11 +34,13 @@ declare const cliOptions: {
|
|
28
34
|
description: string;
|
29
35
|
types: CommandTypes[];
|
30
36
|
defaultOptions: {
|
37
|
+
child: boolean;
|
31
38
|
cwd: string;
|
32
39
|
indexName: string;
|
33
|
-
include: string;
|
40
|
+
include: string[];
|
34
41
|
exclude: never[];
|
35
42
|
clean: boolean;
|
43
|
+
debug: boolean;
|
36
44
|
};
|
37
45
|
optionTitles: {
|
38
46
|
cwd: string;
|
@@ -40,6 +48,8 @@ declare const cliOptions: {
|
|
40
48
|
include: string;
|
41
49
|
exclude: string;
|
42
50
|
clean: string;
|
51
|
+
child: string;
|
52
|
+
debug: string;
|
43
53
|
};
|
44
54
|
optionTypes: {
|
45
55
|
cwd: string;
|
@@ -47,6 +57,8 @@ declare const cliOptions: {
|
|
47
57
|
include: string;
|
48
58
|
exclude: string;
|
49
59
|
clean: string;
|
60
|
+
child: string;
|
61
|
+
debug: string;
|
50
62
|
};
|
51
63
|
action: (options: any) => Promise<void>;
|
52
64
|
};
|
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,8 @@ declare const optionTitles: {
|
|
14
16
|
include: string;
|
15
17
|
exclude: string;
|
16
18
|
clean: string;
|
19
|
+
child: string;
|
20
|
+
debug: string;
|
17
21
|
};
|
18
22
|
declare const optionTypes: {
|
19
23
|
cwd: string;
|
@@ -21,6 +25,8 @@ declare const optionTypes: {
|
|
21
25
|
include: string;
|
22
26
|
exclude: string;
|
23
27
|
clean: string;
|
28
|
+
child: string;
|
29
|
+
debug: string;
|
24
30
|
};
|
25
31
|
declare const cliOptions: {
|
26
32
|
name: string;
|
@@ -28,11 +34,13 @@ declare const cliOptions: {
|
|
28
34
|
description: string;
|
29
35
|
types: CommandTypes[];
|
30
36
|
defaultOptions: {
|
37
|
+
child: boolean;
|
31
38
|
cwd: string;
|
32
39
|
indexName: string;
|
33
|
-
include: string;
|
40
|
+
include: string[];
|
34
41
|
exclude: never[];
|
35
42
|
clean: boolean;
|
43
|
+
debug: boolean;
|
36
44
|
};
|
37
45
|
optionTitles: {
|
38
46
|
cwd: string;
|
@@ -40,6 +48,8 @@ declare const cliOptions: {
|
|
40
48
|
include: string;
|
41
49
|
exclude: string;
|
42
50
|
clean: string;
|
51
|
+
child: string;
|
52
|
+
debug: string;
|
43
53
|
};
|
44
54
|
optionTypes: {
|
45
55
|
cwd: string;
|
@@ -47,6 +57,8 @@ declare const cliOptions: {
|
|
47
57
|
include: string;
|
48
58
|
exclude: string;
|
49
59
|
clean: string;
|
60
|
+
child: string;
|
61
|
+
debug: string;
|
50
62
|
};
|
51
63
|
action: (options: any) => Promise<void>;
|
52
64
|
};
|
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 a=(e
|
4
|
+
var k=Object.defineProperty,O=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var y=(i,e,t)=>e in i?k(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,x=(i,e)=>{for(var t in e||(e={}))I.call(e,t)&&y(i,t,e[t]);if(b)for(var t of b(e))v.call(e,t)&&y(i,t,e[t]);return i},u=(i,e)=>O(i,j(e));var d=(i,e,t)=>new Promise((g,r)=>{var a=n=>{try{c(t.next(n));}catch(p){r(p);}},s=n=>{try{c(t.throw(n));}catch(p){r(p);}},c=n=>n.done?g(n.value):Promise.resolve(n.value).then(a,s);c((t=t.apply(i,e)).next());});var l={name:"@tikkhun/index-generator",version:"0.1.1",description:"",bin:{"tikkhun-index-generator":"dist/cli/index.js"},main:"dist/lib/index.js",module:"dist/lib/index.mjs",types:"dist/lib/index.d.ts",exports:{".":{import:{types:"./dist/lib/index.d.mts",default:"./dist/lib/index.mjs"},require:{types:"./dist/lib/index.d.ts",default:"./dist/lib/index.js"}}},files:["dist"],scripts:{build:"tsup",dev:"tsx ./src/index.ts",test:"vitest"},publishConfig:{access:"public"},keywords:[],author:"",license:"ISC",dependencies:{"@tikkhun/cli-core":"workspace:^","@tikkhun/logger":"workspace:^","@tikkhun/utils-core":"workspace:^",glob:"^11.0.3"},devDependencies:{"@types/node":"^20.3.1",tsup:"^8.5.0",tsx:"^4.20.3",vitest:"^3.2.4"}};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 c=(yield glob.glob("**/*",{cwd:t,ignore:e.exclude})).filter(n=>fs.statSync(o__default.default.join(t,n)).isDirectory());for(let n of c)console.log("\u5BF9\u76EE\u5F55\u8FDB\u884Cindex\u751F\u6210",n),yield f(u(x({},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 a=o__default.default.join(t,e.indexName);if(!(e!=null&&e.clean)&&(yield T(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,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 $=u(x({},m),{child:false});cliCore.echoPackage(l);var q={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664",clean:"\u6E05\u9664\u65E7\u7684",child:"\u5B50\u76EE\u5F55",debug:"\u8C03\u8BD5"},J={cwd:"string",indexName:"string",include:"array",exclude:"array",clean:"boolean",child:"boolean",debug:"boolean"},K={name:l.name,version:l.version,description:l.description,types:[cliCore.CommandTypes.args,cliCore.CommandTypes.prompts],defaultOptions:$,optionTitles:q,optionTypes:J,action:i=>d(null,null,function*(){f(i);})},X=new cliCore.Cli(K);exports.cli=X;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 {echoPackage,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 a=(e
|
4
|
+
var k=Object.defineProperty,O=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var y=(i,e,t)=>e in i?k(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t,x=(i,e)=>{for(var t in e||(e={}))I.call(e,t)&&y(i,t,e[t]);if(b)for(var t of b(e))v.call(e,t)&&y(i,t,e[t]);return i},u=(i,e)=>O(i,j(e));var d=(i,e,t)=>new Promise((g,r)=>{var a=n=>{try{c(t.next(n));}catch(p){r(p);}},s=n=>{try{c(t.throw(n));}catch(p){r(p);}},c=n=>n.done?g(n.value):Promise.resolve(n.value).then(a,s);c((t=t.apply(i,e)).next());});var l={name:"@tikkhun/index-generator",version:"0.1.1",description:"",bin:{"tikkhun-index-generator":"dist/cli/index.js"},main:"dist/lib/index.js",module:"dist/lib/index.mjs",types:"dist/lib/index.d.ts",exports:{".":{import:{types:"./dist/lib/index.d.mts",default:"./dist/lib/index.mjs"},require:{types:"./dist/lib/index.d.ts",default:"./dist/lib/index.js"}}},files:["dist"],scripts:{build:"tsup",dev:"tsx ./src/index.ts",test:"vitest"},publishConfig:{access:"public"},keywords:[],author:"",license:"ISC",dependencies:{"@tikkhun/cli-core":"workspace:^","@tikkhun/logger":"workspace:^","@tikkhun/utils-core":"workspace:^",glob:"^11.0.3"},devDependencies:{"@types/node":"^20.3.1",tsup:"^8.5.0",tsx:"^4.20.3",vitest:"^3.2.4"}};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 c=(yield glob("**/*",{cwd:t,ignore:e.exclude})).filter(n=>statSync(o.join(t,n)).isDirectory());for(let n of c)console.log("\u5BF9\u76EE\u5F55\u8FDB\u884Cindex\u751F\u6210",n),yield f(u(x({},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 a=o.join(t,e.indexName);if(!(e!=null&&e.clean)&&(yield T(a))){console.error(`index\u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8FDB\u884C\u521B\u5EFA,\u6587\u4EF6\u540D\u4E3A${a}`);return}yield writeFile(a,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 $=u(x({},m),{child:false});echoPackage(l);var q={cwd:"\u8DEF\u5F84",indexName:"\u6587\u4EF6\u540D",include:"\u5305\u542B",exclude:"\u6392\u9664",clean:"\u6E05\u9664\u65E7\u7684",child:"\u5B50\u76EE\u5F55",debug:"\u8C03\u8BD5"},J={cwd:"string",indexName:"string",include:"array",exclude:"array",clean:"boolean",child:"boolean",debug:"boolean"},K={name:l.name,version:l.version,description:l.description,types:[CommandTypes.args,CommandTypes.prompts],defaultOptions:$,optionTitles:q,optionTypes:J,action:i=>d(null,null,function*(){f(i);})},X=new Cli(K);export{X 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.
|
3
|
+
"version": "0.1.1",
|
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
|
+
"@tikkhun/logger": "^1.0.8",
|
34
35
|
"@tikkhun/cli-core": "^0.0.28",
|
35
|
-
"@tikkhun/utils-core": "^0.0.22"
|
36
|
-
"@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",
|