@tikkhun/version 2024.7.1 → 2024.7.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/README.md CHANGED
@@ -1,28 +1,36 @@
1
- # Date-version
1
+ # version-manager
2
2
 
3
- 其实就是一个简单的日期版本号。
4
- 可以更新 package.json等 的 version
3
+ 其实就是一个简单的版本控制器。
4
+
5
+ - 可以生成版本,和保存版本
5
6
 
6
7
  ## 需求分析
7
8
 
8
- - 获取版本号
9
- - 时间 -format
9
+ - 生成/获取版本号
10
+ - 时间
11
+ - format
10
12
  - 运行时 编译等环节的版本号
13
+ - node version
14
+ - bytenode version
11
15
  - 自输入版本名称
16
+ - 自己输入
12
17
  - 写入版本号
13
18
  - json、普通txt等的读取与写入
14
19
 
15
20
  ## 安装
16
21
 
17
22
  ```powershell
18
- npm install @tikkhun/date-version -D
23
+ npm install @tikkhun/version -D
19
24
 
20
25
  ```
21
26
 
22
27
  ## 使用
23
28
 
24
29
  ```powershell
25
- date-version get
26
-
30
+ # 单纯获取
31
+ date-version get
32
+ # 更新package.json的版本
27
33
  date-version update
34
+ #
35
+ node-version save
28
36
  ```
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var Y = require('dayjs');
4
+ var C = require('dayjs');
5
5
  var logger = require('@tikkhun/logger');
6
- var q = require('path');
7
6
  var fsExtra = require('fs-extra');
7
+ var q = require('path');
8
8
  var commander = require('commander');
9
9
 
10
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
 
12
- var Y__default = /*#__PURE__*/_interopDefault(Y);
12
+ var C__default = /*#__PURE__*/_interopDefault(C);
13
13
  var q__default = /*#__PURE__*/_interopDefault(q);
14
14
 
15
15
  /**
16
16
  @tikkhun/logger
17
17
  */
18
- var R=Object.defineProperty,V=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var d=(r,t,e)=>t in r?R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,y=(r,t)=>{for(var e in t||(t={}))L.call(t,e)&&d(r,e,t[e]);if(E)for(var e of E(t))U.call(t,e)&&d(r,e,t[e]);return r},P=(r,t)=>V(r,k(t));var o=(r,t)=>()=>(r&&(t=r(r=0)),t);var F=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var a=(r,t,e)=>new Promise((c,i)=>{var I=s=>{try{g(e.next(s));}catch(l){i(l);}},M=s=>{try{g(e.throw(s));}catch(l){i(l);}},g=s=>s.done?c(s.value):Promise.resolve(s.value).then(I,M);g((e=e.apply(r,t)).next());});var f,n,_=o(()=>{f={pattern:"YYYY.MM.DD"},n=class r{constructor(t){this.log=new logger.Logger(this.constructor.name);this.options=Object.assign(f,t);}static get(t){return Y__default.default().format(t)}get(){return r.get(this.options.pattern)}};});var w=o(()=>{});var J=o(()=>{});var O=o(()=>{_();w();J();});var N,h=o(()=>{N=process.cwd();});var u,p,A=o(()=>{h();u={file:"package.json",key:"version"},p=class{constructor(t){this.opts=Object.assign(u,t),this.filePath=q__default.default.join(N,this.opts.file);}update(t){return a(this,null,function*(){try{let e=yield fsExtra.readJson(this.filePath);return yield fsExtra.writeJson(this.filePath,P(y({},e),{[this.opts.key]:t}),{spaces:2}),!0}catch(e){return !1}})}};});var D=o(()=>{});var b=o(()=>{});var S=o(()=>{A();D();b();});var C,m,v=o(()=>{O();S();C={getter:new n,store:new p},m=class{constructor(t){this.opts=Object.assign(C,t);}get(){return this.opts.getter.get()}update(){return a(this,null,function*(){this.get();let e=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(e.map(i=>i.update))).filter(i=>!i).length)throw new Error("update error");return !0}catch(c){return !1}})}};});var G=o(()=>{v();h();S();O();});var H=F(j=>{G();logger.Logger.log("[\u6B22\u8FCE] date-version");commander.program.command("update").description("\u66F4\u65B0JSON").option("-f --format <format>","\u65E5\u671F\u683C\u5F0F",f.pattern).option("-p --path <filePath>","json\u6587\u4EF6\u8DEF\u5F84",u.file).action(r=>a(j,null,function*(){(yield new m({getter:new n({pattern:r.format}),store:new p({file:r.path,key:"version"})}).update())&&logger.Logger.debug("package json \u7684\u7248\u672C\u66F4\u65B0\u6210\u529F");}));commander.program.command("get").description("\u83B7\u53D6\u7248\u672C").option("-f --format <format>","\u65E5\u671F\u683C\u5F0F",f.pattern).action(({format:r})=>{let t=new n({pattern:r});logger.Logger.log(t.get());});commander.program.parse(process.argv);});var dateVersion = H();
18
+ var R=Object.defineProperty,M=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var y=(r,t,e)=>t in r?R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_=(r,t)=>{for(var e in t||(t={}))U.call(t,e)&&y(r,e,t[e]);if(E)for(var e of E(t))F.call(t,e)&&y(r,e,t[e]);return r},d=(r,t)=>M(r,L(t));var o=(r,t)=>()=>(r&&(t=r(r=0)),t);var Y=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var i=(r,t,e)=>new Promise((g,a)=>{var I=s=>{try{h(e.next(s));}catch(O){a(O);}},v=s=>{try{h(e.throw(s));}catch(O){a(O);}},h=s=>s.done?g(s.value):Promise.resolve(s.value).then(I,v);h((e=e.apply(r,t)).next());});var f,n,w=o(()=>{f={pattern:"YYYY.MM.DD"},n=class r{constructor(t){this.log=new logger.Logger(this.constructor.name);this.options=Object.assign(f,t);}static get(t){return C__default.default().format(t)}get(){return r.get(this.options.pattern)}};});var N=o(()=>{});var c,m=o(()=>{c=process.cwd();});var j=o(()=>{m();});var G=o(()=>{});var u=o(()=>{w();N();j();G();});var S,p,b=o(()=>{m();S={file:"package.json",key:"version"},p=class{constructor(t){this.opts=Object.assign(S,t),this.filePath=q__default.default.join(c,this.opts.file);}update(t){return i(this,null,function*(){try{let e=yield fsExtra.readJson(this.filePath);return yield fsExtra.writeJson(this.filePath,d(_({},e),{[this.opts.key]:t}),{spaces:2}),!0}catch(e){return !1}})}};});var k=o(()=>{});var A=o(()=>{m();});var x=o(()=>{b();k();A();});var H,l,J=o(()=>{u();x();H={getter:new n,store:new p},l=class{constructor(t){this.opts=Object.assign(H,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){let t=yield this.get(),e=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(e.map(a=>a.update(t)))).filter(a=>!a).length)throw new Error("update error");return !0}catch(g){return !1}})}};});var V=o(()=>{J();m();x();u();});var K=Y(D=>{V();logger.Logger.log("[\u6B22\u8FCE] date-version");commander.program.command("update").description("\u66F4\u65B0JSON").option("-f --format <format>","\u65E5\u671F\u683C\u5F0F",f.pattern).option("-p --path <filePath>","json\u6587\u4EF6\u8DEF\u5F84",S.file).action(r=>i(D,null,function*(){(yield new l({getter:new n({pattern:r.format}),store:new p({file:r.path,key:"version"})}).update())&&logger.Logger.debug("package json \u7684\u7248\u672C\u66F4\u65B0\u6210\u529F");}));commander.program.command("get").description("\u83B7\u53D6\u7248\u672C").option("-f --format <format>","\u65E5\u671F\u683C\u5F0F",f.pattern).action(({format:r})=>{let t=new n({pattern:r});logger.Logger.log(t.get());});commander.program.parse(process.argv);});var dateVersion = K();
19
19
 
20
20
  module.exports = dateVersion;
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import Y from 'dayjs';
2
+ import C from 'dayjs';
3
3
  import { Logger } from '@tikkhun/logger';
4
- import q from 'path';
5
4
  import { readJson, writeJson } from 'fs-extra';
5
+ import q from 'path';
6
6
  import { program } from 'commander';
7
7
 
8
8
  /**
9
9
  @tikkhun/logger
10
10
  */
11
- var R=Object.defineProperty,V=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var d=(r,t,e)=>t in r?R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,y=(r,t)=>{for(var e in t||(t={}))L.call(t,e)&&d(r,e,t[e]);if(E)for(var e of E(t))U.call(t,e)&&d(r,e,t[e]);return r},P=(r,t)=>V(r,k(t));var o=(r,t)=>()=>(r&&(t=r(r=0)),t);var F=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var a=(r,t,e)=>new Promise((c,i)=>{var I=s=>{try{g(e.next(s));}catch(l){i(l);}},M=s=>{try{g(e.throw(s));}catch(l){i(l);}},g=s=>s.done?c(s.value):Promise.resolve(s.value).then(I,M);g((e=e.apply(r,t)).next());});var f,n,_=o(()=>{f={pattern:"YYYY.MM.DD"},n=class r{constructor(t){this.log=new Logger(this.constructor.name);this.options=Object.assign(f,t);}static get(t){return Y().format(t)}get(){return r.get(this.options.pattern)}};});var w=o(()=>{});var J=o(()=>{});var O=o(()=>{_();w();J();});var N,h=o(()=>{N=process.cwd();});var u,p,A=o(()=>{h();u={file:"package.json",key:"version"},p=class{constructor(t){this.opts=Object.assign(u,t),this.filePath=q.join(N,this.opts.file);}update(t){return a(this,null,function*(){try{let e=yield readJson(this.filePath);return yield writeJson(this.filePath,P(y({},e),{[this.opts.key]:t}),{spaces:2}),!0}catch(e){return !1}})}};});var D=o(()=>{});var b=o(()=>{});var S=o(()=>{A();D();b();});var C,m,v=o(()=>{O();S();C={getter:new n,store:new p},m=class{constructor(t){this.opts=Object.assign(C,t);}get(){return this.opts.getter.get()}update(){return a(this,null,function*(){this.get();let e=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(e.map(i=>i.update))).filter(i=>!i).length)throw new Error("update error");return !0}catch(c){return !1}})}};});var G=o(()=>{v();h();S();O();});var H=F(j=>{G();Logger.log("[\u6B22\u8FCE] date-version");program.command("update").description("\u66F4\u65B0JSON").option("-f --format <format>","\u65E5\u671F\u683C\u5F0F",f.pattern).option("-p --path <filePath>","json\u6587\u4EF6\u8DEF\u5F84",u.file).action(r=>a(j,null,function*(){(yield new m({getter:new n({pattern:r.format}),store:new p({file:r.path,key:"version"})}).update())&&Logger.debug("package json \u7684\u7248\u672C\u66F4\u65B0\u6210\u529F");}));program.command("get").description("\u83B7\u53D6\u7248\u672C").option("-f --format <format>","\u65E5\u671F\u683C\u5F0F",f.pattern).action(({format:r})=>{let t=new n({pattern:r});Logger.log(t.get());});program.parse(process.argv);});var dateVersion = H();
11
+ var R=Object.defineProperty,M=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var y=(r,t,e)=>t in r?R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_=(r,t)=>{for(var e in t||(t={}))U.call(t,e)&&y(r,e,t[e]);if(E)for(var e of E(t))F.call(t,e)&&y(r,e,t[e]);return r},d=(r,t)=>M(r,L(t));var o=(r,t)=>()=>(r&&(t=r(r=0)),t);var Y=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var i=(r,t,e)=>new Promise((g,a)=>{var I=s=>{try{h(e.next(s));}catch(O){a(O);}},v=s=>{try{h(e.throw(s));}catch(O){a(O);}},h=s=>s.done?g(s.value):Promise.resolve(s.value).then(I,v);h((e=e.apply(r,t)).next());});var f,n,w=o(()=>{f={pattern:"YYYY.MM.DD"},n=class r{constructor(t){this.log=new Logger(this.constructor.name);this.options=Object.assign(f,t);}static get(t){return C().format(t)}get(){return r.get(this.options.pattern)}};});var N=o(()=>{});var c,m=o(()=>{c=process.cwd();});var j=o(()=>{m();});var G=o(()=>{});var u=o(()=>{w();N();j();G();});var S,p,b=o(()=>{m();S={file:"package.json",key:"version"},p=class{constructor(t){this.opts=Object.assign(S,t),this.filePath=q.join(c,this.opts.file);}update(t){return i(this,null,function*(){try{let e=yield readJson(this.filePath);return yield writeJson(this.filePath,d(_({},e),{[this.opts.key]:t}),{spaces:2}),!0}catch(e){return !1}})}};});var k=o(()=>{});var A=o(()=>{m();});var x=o(()=>{b();k();A();});var H,l,J=o(()=>{u();x();H={getter:new n,store:new p},l=class{constructor(t){this.opts=Object.assign(H,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){let t=yield this.get(),e=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(e.map(a=>a.update(t)))).filter(a=>!a).length)throw new Error("update error");return !0}catch(g){return !1}})}};});var V=o(()=>{J();m();x();u();});var K=Y(D=>{V();Logger.log("[\u6B22\u8FCE] date-version");program.command("update").description("\u66F4\u65B0JSON").option("-f --format <format>","\u65E5\u671F\u683C\u5F0F",f.pattern).option("-p --path <filePath>","json\u6587\u4EF6\u8DEF\u5F84",S.file).action(r=>i(D,null,function*(){(yield new l({getter:new n({pattern:r.format}),store:new p({file:r.path,key:"version"})}).update())&&Logger.debug("package json \u7684\u7248\u672C\u66F4\u65B0\u6210\u529F");}));program.command("get").description("\u83B7\u53D6\u7248\u672C").option("-f --format <format>","\u65E5\u671F\u683C\u5F0F",f.pattern).action(({format:r})=>{let t=new n({pattern:r});Logger.log(t.get());});program.parse(process.argv);});var dateVersion = K();
12
12
 
13
13
  export { dateVersion as default };
@@ -1,20 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
+ var C = require('dayjs');
4
5
  var logger = require('@tikkhun/logger');
5
- var commander = require('commander');
6
- var M = require('dayjs');
7
- var J = require('path');
8
6
  var fsExtra = require('fs-extra');
9
- var k = require('fs');
7
+ var z = require('path');
8
+ var Q = require('fs');
9
+ var commander = require('commander');
10
10
 
11
11
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
12
 
13
- var M__default = /*#__PURE__*/_interopDefault(M);
14
- var J__default = /*#__PURE__*/_interopDefault(J);
15
- var k__default = /*#__PURE__*/_interopDefault(k);
13
+ var C__default = /*#__PURE__*/_interopDefault(C);
14
+ var z__default = /*#__PURE__*/_interopDefault(z);
15
+ var Q__default = /*#__PURE__*/_interopDefault(Q);
16
16
 
17
17
  /**
18
18
  @tikkhun/logger
19
19
  */
20
- var P=Object.defineProperty,E=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var u=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,O=(e,t)=>{for(var r in t||(t={}))v.call(t,r)&&u(e,r,t[r]);if(h)for(var r of h(t))A.call(t,r)&&u(e,r,t[r]);return e},x=(e,t)=>E(e,_(t));var i=(e,t,r)=>new Promise((c,s)=>{var w=o=>{try{g(r.next(o));}catch(l){s(l);}},y=o=>{try{g(r.throw(o));}catch(l){s(l);}},g=o=>o.done?c(o.value):Promise.resolve(o.value).then(w,y);g((r=r.apply(e,t)).next());});var G={pattern:"YYYY.MM.DD"},n=class e{constructor(t){this.log=new logger.Logger(this.constructor.name);this.options=Object.assign(G,t);}static get(t){return M__default.default().format(t)}get(){return e.get(this.options.pattern)}};var p=class{get(){return process.versions.node}};var S=process.cwd();var b={file:"package.json",key:"version"},a=class{constructor(t){this.opts=Object.assign(b,t),this.filePath=J__default.default.join(S,this.opts.file);}update(t){return i(this,null,function*(){try{let r=yield fsExtra.readJson(this.filePath);return yield fsExtra.writeJson(this.filePath,x(O({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var m=class{constructor(t){this.opts=t,this.filePath=J__default.default.join(this.opts.file);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),k__default.default.writeFileSync(this.filePath,t,"utf8"),!0}catch(r){return !1}}};var L={getter:new n,store:new a},f=class{constructor(t){this.opts=Object.assign(L,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){this.get();let r=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(r.map(s=>s.update))).filter(s=>!s).length)throw new Error("update error");return !0}catch(c){return !1}})}};logger.Logger.log("[\u6B22\u8FCE] node-version");commander.program.command("save").description("\u4FDD\u5B58\u7248\u672C").action(()=>{new f({getter:new p,store:new m({file:".node-version"})}).update(),logger.Logger.debug("node \u7248\u672C\u66F4\u65B0\u6210\u529F");});commander.program.parse(process.argv);
20
+ var D=Object.defineProperty,R=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var T=(r,t,e)=>t in r?D(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,w=(r,t)=>{for(var e in t||(t={}))F.call(t,e)&&T(r,e,t[e]);if(P)for(var e of P(t))U.call(t,e)&&T(r,e,t[e]);return r},y=(r,t)=>R(r,L(t));var o=(r,t)=>()=>(r&&(t=r(r=0)),t);var Y=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var i=(r,t,e)=>new Promise((g,n)=>{var I=s=>{try{u(e.next(s));}catch(O){n(O);}},J=s=>{try{u(e.throw(s));}catch(O){n(O);}},u=s=>s.done?g(s.value):Promise.resolve(s.value).then(I,J);u((e=e.apply(r,t)).next());});var q,m,d=o(()=>{q={pattern:"YYYY.MM.DD"},m=class r{constructor(t){this.log=new logger.Logger(this.constructor.name);this.options=Object.assign(q,t);}static get(t){return C__default.default().format(t)}get(){return r.get(this.options.pattern)}};});var f,E=o(()=>{f=class{get(){return process.versions.node}};});var p,a=o(()=>{p=process.cwd();});var j=o(()=>{a();});var _=o(()=>{});var S=o(()=>{d();E();j();_();});var K,c,b=o(()=>{a();K={file:"package.json",key:"version"},c=class{constructor(t){this.opts=Object.assign(K,t),this.filePath=z__default.default.join(p,this.opts.file);}update(t){return i(this,null,function*(){try{let e=yield fsExtra.readJson(this.filePath);return yield fsExtra.writeJson(this.filePath,y(w({},e),{[this.opts.key]:t}),{spaces:2}),!0}catch(e){return !1}})}};});var G=o(()=>{});var l,N=o(()=>{a();l=class{constructor(t){this.opts=t,this.filePath=z__default.default.join(p,this.opts.file),console.log("this.filePath",this.filePath);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),console.log("this.filePath,text",this.filePath,t),Q__default.default.writeFileSync(this.filePath,t,"utf8"),!0}catch(e){return !1}}};});var x=o(()=>{b();G();N();});var Z,h,k=o(()=>{S();x();Z={getter:new m,store:new c},h=class{constructor(t){this.opts=Object.assign(Z,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){let t=yield this.get(),e=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(e.map(n=>n.update(t)))).filter(n=>!n).length)throw new Error("update error");return !0}catch(g){return !1}})}};});var v=o(()=>{k();a();x();S();});var $=Y(M=>{v();logger.Logger.log("[\u6B22\u8FCE] node-version");commander.program.command("save").description("\u4FDD\u5B58\u7248\u672C").action(()=>i(M,null,function*(){(yield new h({getter:new f,store:new l({file:".node-version"})}).update())&&logger.Logger.debug("node \u7248\u672C\u66F4\u65B0\u6210\u529F");}));commander.program.parse(process.argv);});var nodeVersion = $();
21
+
22
+ module.exports = nodeVersion;
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env node
2
+ import C from 'dayjs';
2
3
  import { Logger } from '@tikkhun/logger';
3
- import { program } from 'commander';
4
- import M from 'dayjs';
5
- import J from 'path';
6
4
  import { readJson, writeJson } from 'fs-extra';
7
- import k from 'fs';
5
+ import z from 'path';
6
+ import Q from 'fs';
7
+ import { program } from 'commander';
8
8
 
9
9
  /**
10
10
  @tikkhun/logger
11
11
  */
12
- var P=Object.defineProperty,E=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var u=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,O=(e,t)=>{for(var r in t||(t={}))v.call(t,r)&&u(e,r,t[r]);if(h)for(var r of h(t))A.call(t,r)&&u(e,r,t[r]);return e},x=(e,t)=>E(e,_(t));var i=(e,t,r)=>new Promise((c,s)=>{var w=o=>{try{g(r.next(o));}catch(l){s(l);}},y=o=>{try{g(r.throw(o));}catch(l){s(l);}},g=o=>o.done?c(o.value):Promise.resolve(o.value).then(w,y);g((r=r.apply(e,t)).next());});var G={pattern:"YYYY.MM.DD"},n=class e{constructor(t){this.log=new Logger(this.constructor.name);this.options=Object.assign(G,t);}static get(t){return M().format(t)}get(){return e.get(this.options.pattern)}};var p=class{get(){return process.versions.node}};var S=process.cwd();var b={file:"package.json",key:"version"},a=class{constructor(t){this.opts=Object.assign(b,t),this.filePath=J.join(S,this.opts.file);}update(t){return i(this,null,function*(){try{let r=yield readJson(this.filePath);return yield writeJson(this.filePath,x(O({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var m=class{constructor(t){this.opts=t,this.filePath=J.join(this.opts.file);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),k.writeFileSync(this.filePath,t,"utf8"),!0}catch(r){return !1}}};var L={getter:new n,store:new a},f=class{constructor(t){this.opts=Object.assign(L,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){this.get();let r=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(r.map(s=>s.update))).filter(s=>!s).length)throw new Error("update error");return !0}catch(c){return !1}})}};Logger.log("[\u6B22\u8FCE] node-version");program.command("save").description("\u4FDD\u5B58\u7248\u672C").action(()=>{new f({getter:new p,store:new m({file:".node-version"})}).update(),Logger.debug("node \u7248\u672C\u66F4\u65B0\u6210\u529F");});program.parse(process.argv);
12
+ var D=Object.defineProperty,R=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var T=(r,t,e)=>t in r?D(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,w=(r,t)=>{for(var e in t||(t={}))F.call(t,e)&&T(r,e,t[e]);if(P)for(var e of P(t))U.call(t,e)&&T(r,e,t[e]);return r},y=(r,t)=>R(r,L(t));var o=(r,t)=>()=>(r&&(t=r(r=0)),t);var Y=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var i=(r,t,e)=>new Promise((g,n)=>{var I=s=>{try{u(e.next(s));}catch(O){n(O);}},J=s=>{try{u(e.throw(s));}catch(O){n(O);}},u=s=>s.done?g(s.value):Promise.resolve(s.value).then(I,J);u((e=e.apply(r,t)).next());});var q,m,d=o(()=>{q={pattern:"YYYY.MM.DD"},m=class r{constructor(t){this.log=new Logger(this.constructor.name);this.options=Object.assign(q,t);}static get(t){return C().format(t)}get(){return r.get(this.options.pattern)}};});var f,E=o(()=>{f=class{get(){return process.versions.node}};});var p,a=o(()=>{p=process.cwd();});var j=o(()=>{a();});var _=o(()=>{});var S=o(()=>{d();E();j();_();});var K,c,b=o(()=>{a();K={file:"package.json",key:"version"},c=class{constructor(t){this.opts=Object.assign(K,t),this.filePath=z.join(p,this.opts.file);}update(t){return i(this,null,function*(){try{let e=yield readJson(this.filePath);return yield writeJson(this.filePath,y(w({},e),{[this.opts.key]:t}),{spaces:2}),!0}catch(e){return !1}})}};});var G=o(()=>{});var l,N=o(()=>{a();l=class{constructor(t){this.opts=t,this.filePath=z.join(p,this.opts.file),console.log("this.filePath",this.filePath);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),console.log("this.filePath,text",this.filePath,t),Q.writeFileSync(this.filePath,t,"utf8"),!0}catch(e){return !1}}};});var x=o(()=>{b();G();N();});var Z,h,k=o(()=>{S();x();Z={getter:new m,store:new c},h=class{constructor(t){this.opts=Object.assign(Z,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){let t=yield this.get(),e=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(e.map(n=>n.update(t)))).filter(n=>!n).length)throw new Error("update error");return !0}catch(g){return !1}})}};});var v=o(()=>{k();a();x();S();});var $=Y(M=>{v();Logger.log("[\u6B22\u8FCE] node-version");program.command("save").description("\u4FDD\u5B58\u7248\u672C").action(()=>i(M,null,function*(){(yield new h({getter:new f,store:new l({file:".node-version"})}).update())&&Logger.debug("node \u7248\u672C\u66F4\u65B0\u6210\u529F");}));program.parse(process.argv);});var nodeVersion = $();
13
+
14
+ export { nodeVersion as default };
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var q = require('dayjs');
5
+ var logger = require('@tikkhun/logger');
6
+ var fsExtra = require('fs-extra');
7
+ var K = require('path');
8
+ var commander = require('commander');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var q__default = /*#__PURE__*/_interopDefault(q);
13
+ var K__default = /*#__PURE__*/_interopDefault(K);
14
+
15
+ /**
16
+ @tikkhun/logger
17
+ */
18
+ var L=Object.defineProperty,F=Object.defineProperties;var U=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var Y=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var d=(o,t,e)=>t in o?L(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,N=(o,t)=>{for(var e in t||(t={}))Y.call(t,e)&&d(o,e,t[e]);if(_)for(var e of _(t))C.call(t,e)&&d(o,e,t[e]);return o},j=(o,t)=>F(o,U(t));var i=(o,t)=>()=>(o&&(t=o(o=0)),t);var X=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var n=(o,t,e)=>new Promise((r,s)=>{var R=p=>{try{u(e.next(p));}catch(S){s(S);}},D=p=>{try{u(e.throw(p));}catch(S){s(S);}},u=p=>p.done?r(p.value):Promise.resolve(p.value).then(R,D);u((e=e.apply(o,t)).next());});var B,g,k=i(()=>{B={pattern:"YYYY.MM.DD"},g=class o{constructor(t){this.log=new logger.Logger(this.constructor.name);this.options=Object.assign(B,t);}static get(t){return q__default.default().format(t)}get(){return o.get(this.options.pattern)}};});var G=i(()=>{});var f,c=i(()=>{f=process.cwd();});var a,h,l,b=i(()=>{c();a=(r=>(r[r.major=0]="major",r[r.minor=1]="minor",r[r.patch=2]="patch",r))(a||{}),h={file:"package.json",position:2,key:"version"},l=class{constructor(t){this.opts=Object.assign(h,t),this.filePath=K__default.default.join(f,this.opts.file);}get(){return n(this,null,function*(){let{[this.opts.key]:t}=yield fsExtra.readJson(this.filePath),[e,r,s]=t.split(".");return this.opts.position===0?[Number(e)+1,r,s].join("."):this.opts.position===1?[e,Number(r)+1,s].join("."):[e,r,Number(s)+1].join(".")})}};});var A=i(()=>{});var P=i(()=>{k();G();b();A();});var T,m,I=i(()=>{c();T={file:"package.json",key:"version"},m=class{constructor(t){this.opts=Object.assign(T,t),this.filePath=K__default.default.join(f,this.opts.file);}update(t){return n(this,null,function*(){try{let e=yield fsExtra.readJson(this.filePath);return yield fsExtra.writeJson(this.filePath,j(N({},e),{[this.opts.key]:t}),{spaces:2}),!0}catch(e){return !1}})}};});var V=i(()=>{});var J=i(()=>{c();});var x=i(()=>{I();V();J();});var $,O,v=i(()=>{P();x();$={getter:new g,store:new m},O=class{constructor(t){this.opts=Object.assign($,t);}get(){return this.opts.getter.get()}update(){return n(this,null,function*(){let t=yield this.get(),e=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(e.map(s=>s.update(t)))).filter(s=>!s).length)throw new Error("update error");return !0}catch(r){return !1}})}};});var M=i(()=>{v();c();x();P();});var tt=X(w=>{M();logger.Logger.log("[\u6B22\u8FCE] date-version");commander.program.command("update").description("\u66F4\u65B0").option("-p --position <position>","\u66F4\u65B0\u4F4D\u7F6E",a[h.position]).option("-f --file <filePath>","json\u6587\u4EF6\u8DEF\u5F84",T.file).action(o=>n(w,null,function*(){let t=a[o.position];(yield new O({getter:new l({position:t,file:o.file}),store:new m({file:o.path,key:"version"})}).update())&&logger.Logger.debug("package json \u7684\u7248\u672C\u66F4\u65B0\u6210\u529F");}));commander.program.command("get").description("\u83B7\u53D6\u7248\u672C").option("-p --position <position>","\u66F4\u65B0\u4F4D\u7F6E",a[h.position]).action(o=>n(w,null,function*(){let t=a[o.position],e=new l({position:t});logger.Logger.log(yield e.get());}));commander.program.parse(process.argv);});var semanticVersion = tt();
19
+
20
+ module.exports = semanticVersion;
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import q from 'dayjs';
3
+ import { Logger } from '@tikkhun/logger';
4
+ import { readJson, writeJson } from 'fs-extra';
5
+ import K from 'path';
6
+ import { program } from 'commander';
7
+
8
+ /**
9
+ @tikkhun/logger
10
+ */
11
+ var L=Object.defineProperty,F=Object.defineProperties;var U=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var Y=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var d=(o,t,e)=>t in o?L(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,N=(o,t)=>{for(var e in t||(t={}))Y.call(t,e)&&d(o,e,t[e]);if(_)for(var e of _(t))C.call(t,e)&&d(o,e,t[e]);return o},j=(o,t)=>F(o,U(t));var i=(o,t)=>()=>(o&&(t=o(o=0)),t);var X=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var n=(o,t,e)=>new Promise((r,s)=>{var R=p=>{try{u(e.next(p));}catch(S){s(S);}},D=p=>{try{u(e.throw(p));}catch(S){s(S);}},u=p=>p.done?r(p.value):Promise.resolve(p.value).then(R,D);u((e=e.apply(o,t)).next());});var B,g,k=i(()=>{B={pattern:"YYYY.MM.DD"},g=class o{constructor(t){this.log=new Logger(this.constructor.name);this.options=Object.assign(B,t);}static get(t){return q().format(t)}get(){return o.get(this.options.pattern)}};});var G=i(()=>{});var f,c=i(()=>{f=process.cwd();});var a,h,l,b=i(()=>{c();a=(r=>(r[r.major=0]="major",r[r.minor=1]="minor",r[r.patch=2]="patch",r))(a||{}),h={file:"package.json",position:2,key:"version"},l=class{constructor(t){this.opts=Object.assign(h,t),this.filePath=K.join(f,this.opts.file);}get(){return n(this,null,function*(){let{[this.opts.key]:t}=yield readJson(this.filePath),[e,r,s]=t.split(".");return this.opts.position===0?[Number(e)+1,r,s].join("."):this.opts.position===1?[e,Number(r)+1,s].join("."):[e,r,Number(s)+1].join(".")})}};});var A=i(()=>{});var P=i(()=>{k();G();b();A();});var T,m,I=i(()=>{c();T={file:"package.json",key:"version"},m=class{constructor(t){this.opts=Object.assign(T,t),this.filePath=K.join(f,this.opts.file);}update(t){return n(this,null,function*(){try{let e=yield readJson(this.filePath);return yield writeJson(this.filePath,j(N({},e),{[this.opts.key]:t}),{spaces:2}),!0}catch(e){return !1}})}};});var V=i(()=>{});var J=i(()=>{c();});var x=i(()=>{I();V();J();});var $,O,v=i(()=>{P();x();$={getter:new g,store:new m},O=class{constructor(t){this.opts=Object.assign($,t);}get(){return this.opts.getter.get()}update(){return n(this,null,function*(){let t=yield this.get(),e=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(e.map(s=>s.update(t)))).filter(s=>!s).length)throw new Error("update error");return !0}catch(r){return !1}})}};});var M=i(()=>{v();c();x();P();});var tt=X(w=>{M();Logger.log("[\u6B22\u8FCE] date-version");program.command("update").description("\u66F4\u65B0").option("-p --position <position>","\u66F4\u65B0\u4F4D\u7F6E",a[h.position]).option("-f --file <filePath>","json\u6587\u4EF6\u8DEF\u5F84",T.file).action(o=>n(w,null,function*(){let t=a[o.position];(yield new O({getter:new l({position:t,file:o.file}),store:new m({file:o.path,key:"version"})}).update())&&Logger.debug("package json \u7684\u7248\u672C\u66F4\u65B0\u6210\u529F");}));program.command("get").description("\u83B7\u53D6\u7248\u672C").option("-p --position <position>","\u66F4\u65B0\u4F4D\u7F6E",a[h.position]).action(o=>n(w,null,function*(){let t=a[o.position],e=new l({position:t});Logger.log(yield e.get());}));program.parse(process.argv);});var semanticVersion = tt();
12
+
13
+ export { semanticVersion as default };
@@ -23,7 +23,7 @@ declare const DEFAULT_VERSION_MANAGER_OPTIONS: VersionManagerOptions;
23
23
  declare class VersionManager {
24
24
  opts: VersionManagerOptions;
25
25
  constructor(options?: Partial<VersionManagerOptions>);
26
- get(): string | number;
26
+ get(): string | number | Promise<string | number>;
27
27
  update(): Promise<boolean>;
28
28
  }
29
29
 
@@ -23,7 +23,7 @@ declare const DEFAULT_VERSION_MANAGER_OPTIONS: VersionManagerOptions;
23
23
  declare class VersionManager {
24
24
  opts: VersionManagerOptions;
25
25
  constructor(options?: Partial<VersionManagerOptions>);
26
- get(): string | number;
26
+ get(): string | number | Promise<string | number>;
27
27
  update(): Promise<boolean>;
28
28
  }
29
29
 
@@ -1,19 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var _ = require('dayjs');
3
+ var j = require('dayjs');
4
4
  var logger = require('@tikkhun/logger');
5
- var J = require('path');
6
5
  var fsExtra = require('fs-extra');
6
+ var G = require('path');
7
7
 
8
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
9
 
10
- var ___default = /*#__PURE__*/_interopDefault(_);
11
- var J__default = /*#__PURE__*/_interopDefault(J);
10
+ var j__default = /*#__PURE__*/_interopDefault(j);
11
+ var G__default = /*#__PURE__*/_interopDefault(G);
12
12
 
13
13
  /**
14
14
  @tikkhun/logger
15
15
  */
16
- var T=Object.defineProperty,y=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var m=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var l=(o,t,r)=>t in o?T(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,h=(o,t)=>{for(var r in t||(t={}))E.call(t,r)&&l(o,r,t[r]);if(m)for(var r of m(t))w.call(t,r)&&l(o,r,t[r]);return o},g=(o,t)=>y(o,P(t));var i=(o,t,r)=>new Promise((a,s)=>{var S=e=>{try{c(r.next(e));}catch(f){s(f);}},x=e=>{try{c(r.throw(e));}catch(f){s(f);}},c=e=>e.done?a(e.value):Promise.resolve(e.value).then(S,x);c((r=r.apply(o,t)).next());});var d={pattern:"YYYY.MM.DD"},n=class o{constructor(t){this.log=new logger.Logger(this.constructor.name);this.options=Object.assign(d,t);}static get(t){return ___default.default().format(t)}get(){return o.get(this.options.pattern)}};var O=process.cwd();var D={file:"package.json",key:"version"},p=class{constructor(t){this.opts=Object.assign(D,t),this.filePath=J__default.default.join(O,this.opts.file);}update(t){return i(this,null,function*(){try{let r=yield fsExtra.readJson(this.filePath);return yield fsExtra.writeJson(this.filePath,g(h({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var G={getter:new n,store:new p},u=class{constructor(t){this.opts=Object.assign(G,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){this.get();let r=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(r.map(s=>s.update))).filter(s=>!s).length)throw new Error("update error");return !0}catch(a){return !1}})}};
16
+ var P=Object.defineProperty,T=Object.defineProperties;var y=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var h=(o,t,r)=>t in o?P(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,g=(o,t)=>{for(var r in t||(t={}))E.call(t,r)&&h(o,r,t[r]);if(l)for(var r of l(t))w.call(t,r)&&h(o,r,t[r]);return o},O=(o,t)=>T(o,y(t));var i=(o,t,r)=>new Promise((m,s)=>{var S=e=>{try{c(r.next(e));}catch(f){s(f);}},x=e=>{try{c(r.throw(e));}catch(f){s(f);}},c=e=>e.done?m(e.value):Promise.resolve(e.value).then(S,x);c((r=r.apply(o,t)).next());});var N={pattern:"YYYY.MM.DD"},n=class o{constructor(t){this.log=new logger.Logger(this.constructor.name);this.options=Object.assign(N,t);}static get(t){return j__default.default().format(t)}get(){return o.get(this.options.pattern)}};var p=process.cwd();var d={file:"package.json",key:"version"},a=class{constructor(t){this.opts=Object.assign(d,t),this.filePath=G__default.default.join(p,this.opts.file);}update(t){return i(this,null,function*(){try{let r=yield fsExtra.readJson(this.filePath);return yield fsExtra.writeJson(this.filePath,O(g({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var I={getter:new n,store:new a},u=class{constructor(t){this.opts=Object.assign(I,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){let t=yield this.get(),r=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(r.map(s=>s.update(t)))).filter(s=>!s).length)throw new Error("update error");return !0}catch(m){return !1}})}};
17
17
 
18
- exports.DEFAULT_VERSION_MANAGER_OPTIONS = G;
18
+ exports.DEFAULT_VERSION_MANAGER_OPTIONS = I;
19
19
  exports.VersionManager = u;
@@ -1,11 +1,11 @@
1
- import _ from 'dayjs';
1
+ import j from 'dayjs';
2
2
  import { Logger } from '@tikkhun/logger';
3
- import J from 'path';
4
3
  import { readJson, writeJson } from 'fs-extra';
4
+ import G from 'path';
5
5
 
6
6
  /**
7
7
  @tikkhun/logger
8
8
  */
9
- var T=Object.defineProperty,y=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var m=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var l=(o,t,r)=>t in o?T(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,h=(o,t)=>{for(var r in t||(t={}))E.call(t,r)&&l(o,r,t[r]);if(m)for(var r of m(t))w.call(t,r)&&l(o,r,t[r]);return o},g=(o,t)=>y(o,P(t));var i=(o,t,r)=>new Promise((a,s)=>{var S=e=>{try{c(r.next(e));}catch(f){s(f);}},x=e=>{try{c(r.throw(e));}catch(f){s(f);}},c=e=>e.done?a(e.value):Promise.resolve(e.value).then(S,x);c((r=r.apply(o,t)).next());});var d={pattern:"YYYY.MM.DD"},n=class o{constructor(t){this.log=new Logger(this.constructor.name);this.options=Object.assign(d,t);}static get(t){return _().format(t)}get(){return o.get(this.options.pattern)}};var O=process.cwd();var D={file:"package.json",key:"version"},p=class{constructor(t){this.opts=Object.assign(D,t),this.filePath=J.join(O,this.opts.file);}update(t){return i(this,null,function*(){try{let r=yield readJson(this.filePath);return yield writeJson(this.filePath,g(h({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var G={getter:new n,store:new p},u=class{constructor(t){this.opts=Object.assign(G,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){this.get();let r=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(r.map(s=>s.update))).filter(s=>!s).length)throw new Error("update error");return !0}catch(a){return !1}})}};
9
+ var P=Object.defineProperty,T=Object.defineProperties;var y=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var h=(o,t,r)=>t in o?P(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,g=(o,t)=>{for(var r in t||(t={}))E.call(t,r)&&h(o,r,t[r]);if(l)for(var r of l(t))w.call(t,r)&&h(o,r,t[r]);return o},O=(o,t)=>T(o,y(t));var i=(o,t,r)=>new Promise((m,s)=>{var S=e=>{try{c(r.next(e));}catch(f){s(f);}},x=e=>{try{c(r.throw(e));}catch(f){s(f);}},c=e=>e.done?m(e.value):Promise.resolve(e.value).then(S,x);c((r=r.apply(o,t)).next());});var N={pattern:"YYYY.MM.DD"},n=class o{constructor(t){this.log=new Logger(this.constructor.name);this.options=Object.assign(N,t);}static get(t){return j().format(t)}get(){return o.get(this.options.pattern)}};var p=process.cwd();var d={file:"package.json",key:"version"},a=class{constructor(t){this.opts=Object.assign(d,t),this.filePath=G.join(p,this.opts.file);}update(t){return i(this,null,function*(){try{let r=yield readJson(this.filePath);return yield writeJson(this.filePath,O(g({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var I={getter:new n,store:new a},u=class{constructor(t){this.opts=Object.assign(I,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){let t=yield this.get(),r=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(r.map(s=>s.update(t)))).filter(s=>!s).length)throw new Error("update error");return !0}catch(m){return !1}})}};
10
10
 
11
- export { G as DEFAULT_VERSION_MANAGER_OPTIONS, u as VersionManager };
11
+ export { I as DEFAULT_VERSION_MANAGER_OPTIONS, u as VersionManager };
@@ -1,5 +1,5 @@
1
1
  interface Getter {
2
- get(): string | number;
2
+ get(): Promise<string | number> | string | number;
3
3
  }
4
4
 
5
5
  export type { Getter };
@@ -1,5 +1,5 @@
1
1
  interface Getter {
2
- get(): string | number;
2
+ get(): Promise<string | number> | string | number;
3
3
  }
4
4
 
5
5
  export type { Getter };
@@ -0,0 +1,34 @@
1
+ import { Getter } from './Getter.mjs';
2
+
3
+ /**
4
+ * @author
5
+ * @file SimpleVersionGetter.ts
6
+ * @fileBase SimpleVersionGetter
7
+ * @path tools\version\lib\getter\SimpleVersionGetter.ts
8
+ * @from
9
+ * @desc
10
+ * @todo
11
+ *
12
+ *
13
+ * @done
14
+ * @example
15
+ */
16
+ declare enum Positions {
17
+ major = 0,
18
+ minor = 1,
19
+ patch = 2
20
+ }
21
+ interface SemanticVersionGetterOptions {
22
+ file: string;
23
+ position: Positions;
24
+ key: string;
25
+ }
26
+ declare const DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS: SemanticVersionGetterOptions;
27
+ declare class SemanticVersionGetter implements Getter {
28
+ opts: SemanticVersionGetterOptions;
29
+ filePath: string;
30
+ constructor(options?: Partial<SemanticVersionGetterOptions>);
31
+ get(): Promise<string>;
32
+ }
33
+
34
+ export { DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS, Positions, SemanticVersionGetter, type SemanticVersionGetterOptions };
@@ -0,0 +1,34 @@
1
+ import { Getter } from './Getter.js';
2
+
3
+ /**
4
+ * @author
5
+ * @file SimpleVersionGetter.ts
6
+ * @fileBase SimpleVersionGetter
7
+ * @path tools\version\lib\getter\SimpleVersionGetter.ts
8
+ * @from
9
+ * @desc
10
+ * @todo
11
+ *
12
+ *
13
+ * @done
14
+ * @example
15
+ */
16
+ declare enum Positions {
17
+ major = 0,
18
+ minor = 1,
19
+ patch = 2
20
+ }
21
+ interface SemanticVersionGetterOptions {
22
+ file: string;
23
+ position: Positions;
24
+ key: string;
25
+ }
26
+ declare const DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS: SemanticVersionGetterOptions;
27
+ declare class SemanticVersionGetter implements Getter {
28
+ opts: SemanticVersionGetterOptions;
29
+ filePath: string;
30
+ constructor(options?: Partial<SemanticVersionGetterOptions>);
31
+ get(): Promise<string>;
32
+ }
33
+
34
+ export { DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS, Positions, SemanticVersionGetter, type SemanticVersionGetterOptions };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var fsExtra = require('fs-extra');
4
+ var j = require('path');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var j__default = /*#__PURE__*/_interopDefault(j);
9
+
10
+ /**
11
+ @tikkhun/logger
12
+ */
13
+ var a=(p,r,o)=>new Promise((t,i)=>{var h=e=>{try{s(o.next(e));}catch(n){i(n);}},f=e=>{try{s(o.throw(e));}catch(n){i(n);}},s=e=>e.done?t(e.value):Promise.resolve(e.value).then(h,f);s((o=o.apply(p,r)).next());});var m=process.cwd();var u=(t=>(t[t.major=0]="major",t[t.minor=1]="minor",t[t.patch=2]="patch",t))(u||{}),O={file:"package.json",position:2,key:"version"},c=class{constructor(r){this.opts=Object.assign(O,r),this.filePath=j__default.default.join(m,this.opts.file);}get(){return a(this,null,function*(){let{[this.opts.key]:r}=yield fsExtra.readJson(this.filePath),[o,t,i]=r.split(".");return this.opts.position===0?[Number(o)+1,t,i].join("."):this.opts.position===1?[o,Number(t)+1,i].join("."):[o,t,Number(i)+1].join(".")})}};
14
+
15
+ exports.DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS = O;
16
+ exports.Positions = u;
17
+ exports.SemanticVersionGetter = c;
@@ -0,0 +1,9 @@
1
+ import { readJson } from 'fs-extra';
2
+ import j from 'path';
3
+
4
+ /**
5
+ @tikkhun/logger
6
+ */
7
+ var a=(p,r,o)=>new Promise((t,i)=>{var h=e=>{try{s(o.next(e));}catch(n){i(n);}},f=e=>{try{s(o.throw(e));}catch(n){i(n);}},s=e=>e.done?t(e.value):Promise.resolve(e.value).then(h,f);s((o=o.apply(p,r)).next());});var m=process.cwd();var u=(t=>(t[t.major=0]="major",t[t.minor=1]="minor",t[t.patch=2]="patch",t))(u||{}),O={file:"package.json",position:2,key:"version"},c=class{constructor(r){this.opts=Object.assign(O,r),this.filePath=j.join(m,this.opts.file);}get(){return a(this,null,function*(){let{[this.opts.key]:r}=yield readJson(this.filePath),[o,t,i]=r.split(".");return this.opts.position===0?[Number(o)+1,t,i].join("."):this.opts.position===1?[o,Number(t)+1,i].join("."):[o,t,Number(i)+1].join(".")})}};
8
+
9
+ export { O as DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS, u as Positions, c as SemanticVersionGetter };
@@ -1,4 +1,5 @@
1
1
  export { DEFAULT_DATE_VERSION_GETTER_OPTIONS, DateVersionGetter, Options } from './DateVersionGetter.mjs';
2
2
  export { NodeVersionGetter } from './NodeVersionGetter.mjs';
3
+ export { DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS, Positions, SemanticVersionGetter, SemanticVersionGetterOptions } from './SemanticVersionGetter.mjs';
3
4
  export { Getter } from './Getter.mjs';
4
5
  import '@tikkhun/logger';
@@ -1,4 +1,5 @@
1
1
  export { DEFAULT_DATE_VERSION_GETTER_OPTIONS, DateVersionGetter, Options } from './DateVersionGetter.js';
2
2
  export { NodeVersionGetter } from './NodeVersionGetter.js';
3
+ export { DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS, Positions, SemanticVersionGetter, SemanticVersionGetterOptions } from './SemanticVersionGetter.js';
3
4
  export { Getter } from './Getter.js';
4
5
  import '@tikkhun/logger';
@@ -1,17 +1,23 @@
1
1
  'use strict';
2
2
 
3
- var s = require('dayjs');
3
+ var O = require('dayjs');
4
4
  var logger = require('@tikkhun/logger');
5
+ var fsExtra = require('fs-extra');
6
+ var E = require('path');
5
7
 
6
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
9
 
8
- var s__default = /*#__PURE__*/_interopDefault(s);
10
+ var O__default = /*#__PURE__*/_interopDefault(O);
11
+ var E__default = /*#__PURE__*/_interopDefault(E);
9
12
 
10
13
  /**
11
14
  @tikkhun/logger
12
15
  */
13
- var p={pattern:"YYYY.MM.DD"},o=class r{constructor(t){this.log=new logger.Logger(this.constructor.name);this.options=Object.assign(p,t);}static get(t){return s__default.default().format(t)}get(){return r.get(this.options.pattern)}};var e=class{get(){return process.versions.node}};
16
+ var m=(s,o,r)=>new Promise((t,i)=>{var h=e=>{try{n(r.next(e));}catch(p){i(p);}},g=e=>{try{n(r.throw(e));}catch(p){i(p);}},n=e=>e.done?t(e.value):Promise.resolve(e.value).then(h,g);n((r=r.apply(s,o)).next());});var x={pattern:"YYYY.MM.DD"},a=class s{constructor(o){this.log=new logger.Logger(this.constructor.name);this.options=Object.assign(x,o);}static get(o){return O__default.default().format(o)}get(){return s.get(this.options.pattern)}};var c=class{get(){return process.versions.node}};var f=process.cwd();var T=(t=>(t[t.major=0]="major",t[t.minor=1]="minor",t[t.patch=2]="patch",t))(T||{}),G={file:"package.json",position:2,key:"version"},l=class{constructor(o){this.opts=Object.assign(G,o),this.filePath=E__default.default.join(f,this.opts.file);}get(){return m(this,null,function*(){let{[this.opts.key]:o}=yield fsExtra.readJson(this.filePath),[r,t,i]=o.split(".");return this.opts.position===0?[Number(r)+1,t,i].join("."):this.opts.position===1?[r,Number(t)+1,i].join("."):[r,t,Number(i)+1].join(".")})}};
14
17
 
15
- exports.DEFAULT_DATE_VERSION_GETTER_OPTIONS = p;
16
- exports.DateVersionGetter = o;
17
- exports.NodeVersionGetter = e;
18
+ exports.DEFAULT_DATE_VERSION_GETTER_OPTIONS = x;
19
+ exports.DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS = G;
20
+ exports.DateVersionGetter = a;
21
+ exports.NodeVersionGetter = c;
22
+ exports.Positions = T;
23
+ exports.SemanticVersionGetter = l;
@@ -1,9 +1,11 @@
1
- import s from 'dayjs';
1
+ import O from 'dayjs';
2
2
  import { Logger } from '@tikkhun/logger';
3
+ import { readJson } from 'fs-extra';
4
+ import E from 'path';
3
5
 
4
6
  /**
5
7
  @tikkhun/logger
6
8
  */
7
- var p={pattern:"YYYY.MM.DD"},o=class r{constructor(t){this.log=new Logger(this.constructor.name);this.options=Object.assign(p,t);}static get(t){return s().format(t)}get(){return r.get(this.options.pattern)}};var e=class{get(){return process.versions.node}};
9
+ var m=(s,o,r)=>new Promise((t,i)=>{var h=e=>{try{n(r.next(e));}catch(p){i(p);}},g=e=>{try{n(r.throw(e));}catch(p){i(p);}},n=e=>e.done?t(e.value):Promise.resolve(e.value).then(h,g);n((r=r.apply(s,o)).next());});var x={pattern:"YYYY.MM.DD"},a=class s{constructor(o){this.log=new Logger(this.constructor.name);this.options=Object.assign(x,o);}static get(o){return O().format(o)}get(){return s.get(this.options.pattern)}};var c=class{get(){return process.versions.node}};var f=process.cwd();var T=(t=>(t[t.major=0]="major",t[t.minor=1]="minor",t[t.patch=2]="patch",t))(T||{}),G={file:"package.json",position:2,key:"version"},l=class{constructor(o){this.opts=Object.assign(G,o),this.filePath=E.join(f,this.opts.file);}get(){return m(this,null,function*(){let{[this.opts.key]:o}=yield readJson(this.filePath),[r,t,i]=o.split(".");return this.opts.position===0?[Number(r)+1,t,i].join("."):this.opts.position===1?[r,Number(t)+1,i].join("."):[r,t,Number(i)+1].join(".")})}};
8
10
 
9
- export { p as DEFAULT_DATE_VERSION_GETTER_OPTIONS, o as DateVersionGetter, e as NodeVersionGetter };
11
+ export { x as DEFAULT_DATE_VERSION_GETTER_OPTIONS, G as DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS, a as DateVersionGetter, c as NodeVersionGetter, T as Positions, l as SemanticVersionGetter };
@@ -5,5 +5,6 @@ export { Store, StoreOptions } from './store/Store.mjs';
5
5
  export { DEFAULT_TEXT_STORE_OPTIONS, TextStore, TextStoreOptions } from './store/TextStore.mjs';
6
6
  export { DEFAULT_DATE_VERSION_GETTER_OPTIONS, DateVersionGetter, Options } from './getter/DateVersionGetter.mjs';
7
7
  export { NodeVersionGetter } from './getter/NodeVersionGetter.mjs';
8
+ export { DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS, Positions, SemanticVersionGetter, SemanticVersionGetterOptions } from './getter/SemanticVersionGetter.mjs';
8
9
  export { Getter } from './getter/Getter.mjs';
9
10
  import '@tikkhun/logger';
@@ -5,5 +5,6 @@ export { Store, StoreOptions } from './store/Store.js';
5
5
  export { DEFAULT_TEXT_STORE_OPTIONS, TextStore, TextStoreOptions } from './store/TextStore.js';
6
6
  export { DEFAULT_DATE_VERSION_GETTER_OPTIONS, DateVersionGetter, Options } from './getter/DateVersionGetter.js';
7
7
  export { NodeVersionGetter } from './getter/NodeVersionGetter.js';
8
+ export { DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS, Positions, SemanticVersionGetter, SemanticVersionGetterOptions } from './getter/SemanticVersionGetter.js';
8
9
  export { Getter } from './getter/Getter.js';
9
10
  import '@tikkhun/logger';
package/dist/lib/index.js CHANGED
@@ -1,29 +1,32 @@
1
1
  'use strict';
2
2
 
3
- var d = require('dayjs');
3
+ var G = require('dayjs');
4
4
  var logger = require('@tikkhun/logger');
5
- var j = require('path');
6
5
  var fsExtra = require('fs-extra');
7
- var I = require('fs');
6
+ var I = require('path');
7
+ var F = require('fs');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
11
- var d__default = /*#__PURE__*/_interopDefault(d);
12
- var j__default = /*#__PURE__*/_interopDefault(j);
11
+ var G__default = /*#__PURE__*/_interopDefault(G);
13
12
  var I__default = /*#__PURE__*/_interopDefault(I);
13
+ var F__default = /*#__PURE__*/_interopDefault(F);
14
14
 
15
15
  /**
16
16
  @tikkhun/logger
17
17
  */
18
- var P=Object.defineProperty,E=Object.defineProperties;var w=Object.getOwnPropertyDescriptors;var c=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var l=(o,t,r)=>t in o?P(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,h=(o,t)=>{for(var r in t||(t={}))_.call(t,r)&&l(o,r,t[r]);if(c)for(var r of c(t))A.call(t,r)&&l(o,r,t[r]);return o},g=(o,t)=>E(o,w(t));var i=(o,t,r)=>new Promise((a,s)=>{var T=e=>{try{f(r.next(e));}catch(m){s(m);}},y=e=>{try{f(r.throw(e));}catch(m){s(m);}},f=e=>e.done?a(e.value):Promise.resolve(e.value).then(T,y);f((r=r.apply(o,t)).next());});var N={pattern:"YYYY.MM.DD"},n=class o{constructor(t){this.log=new logger.Logger(this.constructor.name);this.options=Object.assign(N,t);}static get(t){return d__default.default().format(t)}get(){return o.get(this.options.pattern)}};var O=class{get(){return process.versions.node}};var u=process.cwd();var k={file:"package.json",key:"version"},p=class{constructor(t){this.opts=Object.assign(k,t),this.filePath=j__default.default.join(u,this.opts.file);}update(t){return i(this,null,function*(){try{let r=yield fsExtra.readJson(this.filePath);return yield fsExtra.writeJson(this.filePath,g(h({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var W={},x=class{constructor(t){this.opts=t,this.filePath=j__default.default.join(this.opts.file);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),I__default.default.writeFileSync(this.filePath,t,"utf8"),!0}catch(r){return !1}}};var R={getter:new n,store:new p},S=class{constructor(t){this.opts=Object.assign(R,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){this.get();let r=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(r.map(s=>s.update))).filter(s=>!s).length)throw new Error("update error");return !0}catch(a){return !1}})}};
18
+ var E=Object.defineProperty,w=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var h=(o,t,r)=>t in o?E(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,g=(o,t)=>{for(var r in t||(t={}))_.call(t,r)&&h(o,r,t[r]);if(l)for(var r of l(t))N.call(t,r)&&h(o,r,t[r]);return o},O=(o,t)=>w(o,j(t));var n=(o,t,r)=>new Promise((e,s)=>{var T=i=>{try{f(r.next(i));}catch(c){s(c);}},y=i=>{try{f(r.throw(i));}catch(c){s(c);}},f=i=>i.done?e(i.value):Promise.resolve(i.value).then(T,y);f((r=r.apply(o,t)).next());});var A={pattern:"YYYY.MM.DD"},a=class o{constructor(t){this.log=new logger.Logger(this.constructor.name);this.options=Object.assign(A,t);}static get(t){return G__default.default().format(t)}get(){return o.get(this.options.pattern)}};var u=class{get(){return process.versions.node}};var p=process.cwd();var J=(e=>(e[e.major=0]="major",e[e.minor=1]="minor",e[e.patch=2]="patch",e))(J||{}),V={file:"package.json",position:2,key:"version"},S=class{constructor(t){this.opts=Object.assign(V,t),this.filePath=I__default.default.join(p,this.opts.file);}get(){return n(this,null,function*(){let{[this.opts.key]:t}=yield fsExtra.readJson(this.filePath),[r,e,s]=t.split(".");return this.opts.position===0?[Number(r)+1,e,s].join("."):this.opts.position===1?[r,Number(e)+1,s].join("."):[r,e,Number(s)+1].join(".")})}};var M={file:"package.json",key:"version"},m=class{constructor(t){this.opts=Object.assign(M,t),this.filePath=I__default.default.join(p,this.opts.file);}update(t){return n(this,null,function*(){try{let r=yield fsExtra.readJson(this.filePath);return yield fsExtra.writeJson(this.filePath,O(g({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var at={},x=class{constructor(t){this.opts=t,this.filePath=I__default.default.join(p,this.opts.file),console.log("this.filePath",this.filePath);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),console.log("this.filePath,text",this.filePath,t),F__default.default.writeFileSync(this.filePath,t,"utf8"),!0}catch(r){return !1}}};var U={getter:new a,store:new m},P=class{constructor(t){this.opts=Object.assign(U,t);}get(){return this.opts.getter.get()}update(){return n(this,null,function*(){let t=yield this.get(),r=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(r.map(s=>s.update(t)))).filter(s=>!s).length)throw new Error("update error");return !0}catch(e){return !1}})}};
19
19
 
20
- exports.DEFAULT_DATE_VERSION_GETTER_OPTIONS = N;
21
- exports.DEFAULT_JSON_STORE_OPTIONS = k;
22
- exports.DEFAULT_TEXT_STORE_OPTIONS = W;
23
- exports.DEFAULT_VERSION_MANAGER_OPTIONS = R;
24
- exports.DateVersionGetter = n;
25
- exports.JsonStore = p;
26
- exports.NodeVersionGetter = O;
20
+ exports.DEFAULT_DATE_VERSION_GETTER_OPTIONS = A;
21
+ exports.DEFAULT_JSON_STORE_OPTIONS = M;
22
+ exports.DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS = V;
23
+ exports.DEFAULT_TEXT_STORE_OPTIONS = at;
24
+ exports.DEFAULT_VERSION_MANAGER_OPTIONS = U;
25
+ exports.DateVersionGetter = a;
26
+ exports.JsonStore = m;
27
+ exports.NodeVersionGetter = u;
28
+ exports.Positions = J;
29
+ exports.SemanticVersionGetter = S;
27
30
  exports.TextStore = x;
28
- exports.VersionManager = S;
29
- exports.workspace = u;
31
+ exports.VersionManager = P;
32
+ exports.workspace = p;
@@ -1,12 +1,12 @@
1
- import d from 'dayjs';
1
+ import G from 'dayjs';
2
2
  import { Logger } from '@tikkhun/logger';
3
- import j from 'path';
4
3
  import { readJson, writeJson } from 'fs-extra';
5
- import I from 'fs';
4
+ import I from 'path';
5
+ import F from 'fs';
6
6
 
7
7
  /**
8
8
  @tikkhun/logger
9
9
  */
10
- var P=Object.defineProperty,E=Object.defineProperties;var w=Object.getOwnPropertyDescriptors;var c=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var l=(o,t,r)=>t in o?P(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,h=(o,t)=>{for(var r in t||(t={}))_.call(t,r)&&l(o,r,t[r]);if(c)for(var r of c(t))A.call(t,r)&&l(o,r,t[r]);return o},g=(o,t)=>E(o,w(t));var i=(o,t,r)=>new Promise((a,s)=>{var T=e=>{try{f(r.next(e));}catch(m){s(m);}},y=e=>{try{f(r.throw(e));}catch(m){s(m);}},f=e=>e.done?a(e.value):Promise.resolve(e.value).then(T,y);f((r=r.apply(o,t)).next());});var N={pattern:"YYYY.MM.DD"},n=class o{constructor(t){this.log=new Logger(this.constructor.name);this.options=Object.assign(N,t);}static get(t){return d().format(t)}get(){return o.get(this.options.pattern)}};var O=class{get(){return process.versions.node}};var u=process.cwd();var k={file:"package.json",key:"version"},p=class{constructor(t){this.opts=Object.assign(k,t),this.filePath=j.join(u,this.opts.file);}update(t){return i(this,null,function*(){try{let r=yield readJson(this.filePath);return yield writeJson(this.filePath,g(h({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var W={},x=class{constructor(t){this.opts=t,this.filePath=j.join(this.opts.file);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),I.writeFileSync(this.filePath,t,"utf8"),!0}catch(r){return !1}}};var R={getter:new n,store:new p},S=class{constructor(t){this.opts=Object.assign(R,t);}get(){return this.opts.getter.get()}update(){return i(this,null,function*(){this.get();let r=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(r.map(s=>s.update))).filter(s=>!s).length)throw new Error("update error");return !0}catch(a){return !1}})}};
10
+ var E=Object.defineProperty,w=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var h=(o,t,r)=>t in o?E(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,g=(o,t)=>{for(var r in t||(t={}))_.call(t,r)&&h(o,r,t[r]);if(l)for(var r of l(t))N.call(t,r)&&h(o,r,t[r]);return o},O=(o,t)=>w(o,j(t));var n=(o,t,r)=>new Promise((e,s)=>{var T=i=>{try{f(r.next(i));}catch(c){s(c);}},y=i=>{try{f(r.throw(i));}catch(c){s(c);}},f=i=>i.done?e(i.value):Promise.resolve(i.value).then(T,y);f((r=r.apply(o,t)).next());});var A={pattern:"YYYY.MM.DD"},a=class o{constructor(t){this.log=new Logger(this.constructor.name);this.options=Object.assign(A,t);}static get(t){return G().format(t)}get(){return o.get(this.options.pattern)}};var u=class{get(){return process.versions.node}};var p=process.cwd();var J=(e=>(e[e.major=0]="major",e[e.minor=1]="minor",e[e.patch=2]="patch",e))(J||{}),V={file:"package.json",position:2,key:"version"},S=class{constructor(t){this.opts=Object.assign(V,t),this.filePath=I.join(p,this.opts.file);}get(){return n(this,null,function*(){let{[this.opts.key]:t}=yield readJson(this.filePath),[r,e,s]=t.split(".");return this.opts.position===0?[Number(r)+1,e,s].join("."):this.opts.position===1?[r,Number(e)+1,s].join("."):[r,e,Number(s)+1].join(".")})}};var M={file:"package.json",key:"version"},m=class{constructor(t){this.opts=Object.assign(M,t),this.filePath=I.join(p,this.opts.file);}update(t){return n(this,null,function*(){try{let r=yield readJson(this.filePath);return yield writeJson(this.filePath,O(g({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var at={},x=class{constructor(t){this.opts=t,this.filePath=I.join(p,this.opts.file),console.log("this.filePath",this.filePath);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),console.log("this.filePath,text",this.filePath,t),F.writeFileSync(this.filePath,t,"utf8"),!0}catch(r){return !1}}};var U={getter:new a,store:new m},P=class{constructor(t){this.opts=Object.assign(U,t);}get(){return this.opts.getter.get()}update(){return n(this,null,function*(){let t=yield this.get(),r=Array.isArray(this.opts.store)?this.opts.store:[this.opts.store];try{if((yield Promise.all(r.map(s=>s.update(t)))).filter(s=>!s).length)throw new Error("update error");return !0}catch(e){return !1}})}};
11
11
 
12
- export { N as DEFAULT_DATE_VERSION_GETTER_OPTIONS, k as DEFAULT_JSON_STORE_OPTIONS, W as DEFAULT_TEXT_STORE_OPTIONS, R as DEFAULT_VERSION_MANAGER_OPTIONS, n as DateVersionGetter, p as JsonStore, O as NodeVersionGetter, x as TextStore, S as VersionManager, u as workspace };
12
+ export { A as DEFAULT_DATE_VERSION_GETTER_OPTIONS, M as DEFAULT_JSON_STORE_OPTIONS, V as DEFAULT_SEMANTIC_VERSION_GETTER_OPTIONS, at as DEFAULT_TEXT_STORE_OPTIONS, U as DEFAULT_VERSION_MANAGER_OPTIONS, a as DateVersionGetter, m as JsonStore, u as NodeVersionGetter, J as Positions, S as SemanticVersionGetter, x as TextStore, P as VersionManager, p as workspace };
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var o = require('fs');
3
+ var e = require('fs');
4
4
  var i = require('path');
5
5
 
6
6
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
7
 
8
- var o__default = /*#__PURE__*/_interopDefault(o);
8
+ var e__default = /*#__PURE__*/_interopDefault(e);
9
9
  var i__default = /*#__PURE__*/_interopDefault(i);
10
10
 
11
11
  /**
12
12
  @tikkhun/logger
13
13
  */
14
- var n={},r=class{constructor(t){this.opts=t,this.filePath=i__default.default.join(this.opts.file);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),o__default.default.writeFileSync(this.filePath,t,"utf8"),!0}catch(s){return !1}}};
14
+ var o=process.cwd();var n={},r=class{constructor(t){this.opts=t,this.filePath=i__default.default.join(o,this.opts.file),console.log("this.filePath",this.filePath);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),console.log("this.filePath,text",this.filePath,t),e__default.default.writeFileSync(this.filePath,t,"utf8"),!0}catch(p){return !1}}};
15
15
 
16
16
  exports.DEFAULT_TEXT_STORE_OPTIONS = n;
17
17
  exports.TextStore = r;
@@ -1,9 +1,9 @@
1
- import o from 'fs';
1
+ import e from 'fs';
2
2
  import i from 'path';
3
3
 
4
4
  /**
5
5
  @tikkhun/logger
6
6
  */
7
- var n={},r=class{constructor(t){this.opts=t,this.filePath=i.join(this.opts.file);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),o.writeFileSync(this.filePath,t,"utf8"),!0}catch(s){return !1}}};
7
+ var o=process.cwd();var n={},r=class{constructor(t){this.opts=t,this.filePath=i.join(o,this.opts.file),console.log("this.filePath",this.filePath);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),console.log("this.filePath,text",this.filePath,t),e.writeFileSync(this.filePath,t,"utf8"),!0}catch(p){return !1}}};
8
8
 
9
9
  export { n as DEFAULT_TEXT_STORE_OPTIONS, r as TextStore };
@@ -1,20 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var J = require('path');
3
+ var k = require('path');
4
4
  var fsExtra = require('fs-extra');
5
5
  var d = require('fs');
6
6
 
7
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
 
9
- var J__default = /*#__PURE__*/_interopDefault(J);
9
+ var k__default = /*#__PURE__*/_interopDefault(k);
10
10
  var d__default = /*#__PURE__*/_interopDefault(d);
11
11
 
12
12
  /**
13
13
  @tikkhun/logger
14
14
  */
15
- var g=Object.defineProperty,P=Object.defineProperties;var T=Object.getOwnPropertyDescriptors;var p=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var a=(o,t,r)=>t in o?g(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,f=(o,t)=>{for(var r in t||(t={}))x.call(t,r)&&a(o,r,t[r]);if(p)for(var r of p(t))w.call(t,r)&&a(o,r,t[r]);return o},c=(o,t)=>P(o,T(t));var m=(o,t,r)=>new Promise((S,n)=>{var u=e=>{try{s(r.next(e));}catch(i){n(i);}},y=e=>{try{s(r.throw(e));}catch(i){n(i);}},s=e=>e.done?S(e.value):Promise.resolve(e.value).then(u,y);s((r=r.apply(o,t)).next());});var h=process.cwd();var E={file:"package.json",key:"version"},l=class{constructor(t){this.opts=Object.assign(E,t),this.filePath=J__default.default.join(h,this.opts.file);}update(t){return m(this,null,function*(){try{let r=yield fsExtra.readJson(this.filePath);return yield fsExtra.writeJson(this.filePath,c(f({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var R={},O=class{constructor(t){this.opts=t,this.filePath=J__default.default.join(this.opts.file);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),d__default.default.writeFileSync(this.filePath,t,"utf8"),!0}catch(r){return !1}}};
15
+ var u=Object.defineProperty,y=Object.defineProperties;var T=Object.getOwnPropertyDescriptors;var a=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var f=(r,t,o)=>t in r?u(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o,h=(r,t)=>{for(var o in t||(t={}))x.call(t,o)&&f(r,o,t[o]);if(a)for(var o of a(t))w.call(t,o)&&f(r,o,t[o]);return r},l=(r,t)=>y(r,T(t));var c=(r,t,o)=>new Promise((S,p)=>{var P=e=>{try{s(o.next(e));}catch(n){p(n);}},g=e=>{try{s(o.throw(e));}catch(n){p(n);}},s=e=>e.done?S(e.value):Promise.resolve(e.value).then(P,g);s((o=o.apply(r,t)).next());});var i=process.cwd();var E={file:"package.json",key:"version"},m=class{constructor(t){this.opts=Object.assign(E,t),this.filePath=k__default.default.join(i,this.opts.file);}update(t){return c(this,null,function*(){try{let o=yield fsExtra.readJson(this.filePath);return yield fsExtra.writeJson(this.filePath,l(h({},o),{[this.opts.key]:t}),{spaces:2}),!0}catch(o){return !1}})}};var R={},O=class{constructor(t){this.opts=t,this.filePath=k__default.default.join(i,this.opts.file),console.log("this.filePath",this.filePath);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),console.log("this.filePath,text",this.filePath,t),d__default.default.writeFileSync(this.filePath,t,"utf8"),!0}catch(o){return !1}}};
16
16
 
17
17
  exports.DEFAULT_JSON_STORE_OPTIONS = E;
18
18
  exports.DEFAULT_TEXT_STORE_OPTIONS = R;
19
- exports.JsonStore = l;
19
+ exports.JsonStore = m;
20
20
  exports.TextStore = O;
@@ -1,10 +1,10 @@
1
- import J from 'path';
1
+ import k from 'path';
2
2
  import { readJson, writeJson } from 'fs-extra';
3
3
  import d from 'fs';
4
4
 
5
5
  /**
6
6
  @tikkhun/logger
7
7
  */
8
- var g=Object.defineProperty,P=Object.defineProperties;var T=Object.getOwnPropertyDescriptors;var p=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var a=(o,t,r)=>t in o?g(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,f=(o,t)=>{for(var r in t||(t={}))x.call(t,r)&&a(o,r,t[r]);if(p)for(var r of p(t))w.call(t,r)&&a(o,r,t[r]);return o},c=(o,t)=>P(o,T(t));var m=(o,t,r)=>new Promise((S,n)=>{var u=e=>{try{s(r.next(e));}catch(i){n(i);}},y=e=>{try{s(r.throw(e));}catch(i){n(i);}},s=e=>e.done?S(e.value):Promise.resolve(e.value).then(u,y);s((r=r.apply(o,t)).next());});var h=process.cwd();var E={file:"package.json",key:"version"},l=class{constructor(t){this.opts=Object.assign(E,t),this.filePath=J.join(h,this.opts.file);}update(t){return m(this,null,function*(){try{let r=yield readJson(this.filePath);return yield writeJson(this.filePath,c(f({},r),{[this.opts.key]:t}),{spaces:2}),!0}catch(r){return !1}})}};var R={},O=class{constructor(t){this.opts=t,this.filePath=J.join(this.opts.file);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),d.writeFileSync(this.filePath,t,"utf8"),!0}catch(r){return !1}}};
8
+ var u=Object.defineProperty,y=Object.defineProperties;var T=Object.getOwnPropertyDescriptors;var a=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var f=(r,t,o)=>t in r?u(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o,h=(r,t)=>{for(var o in t||(t={}))x.call(t,o)&&f(r,o,t[o]);if(a)for(var o of a(t))w.call(t,o)&&f(r,o,t[o]);return r},l=(r,t)=>y(r,T(t));var c=(r,t,o)=>new Promise((S,p)=>{var P=e=>{try{s(o.next(e));}catch(n){p(n);}},g=e=>{try{s(o.throw(e));}catch(n){p(n);}},s=e=>e.done?S(e.value):Promise.resolve(e.value).then(P,g);s((o=o.apply(r,t)).next());});var i=process.cwd();var E={file:"package.json",key:"version"},m=class{constructor(t){this.opts=Object.assign(E,t),this.filePath=k.join(i,this.opts.file);}update(t){return c(this,null,function*(){try{let o=yield readJson(this.filePath);return yield writeJson(this.filePath,l(h({},o),{[this.opts.key]:t}),{spaces:2}),!0}catch(o){return !1}})}};var R={},O=class{constructor(t){this.opts=t,this.filePath=k.join(i,this.opts.file),console.log("this.filePath",this.filePath);}update(t){try{return typeof t!="string"&&(t=JSON.stringify(t)),console.log("this.filePath,text",this.filePath,t),d.writeFileSync(this.filePath,t,"utf8"),!0}catch(o){return !1}}};
9
9
 
10
- export { E as DEFAULT_JSON_STORE_OPTIONS, R as DEFAULT_TEXT_STORE_OPTIONS, l as JsonStore, O as TextStore };
10
+ export { E as DEFAULT_JSON_STORE_OPTIONS, R as DEFAULT_TEXT_STORE_OPTIONS, m as JsonStore, O as TextStore };
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@tikkhun/version",
3
- "version": "2024.07.1",
3
+ "version": "2024.07.03",
4
4
  "description": "",
5
5
  "bin": {
6
6
  "date-version": "./dist/cli/date-version.js",
7
- "node-version": "./dist/cli/node-version.js"
7
+ "node-version": "./dist/cli/node-version.js",
8
+ "semantic-version": "./dist/cli/semantic-version.js"
8
9
  },
9
10
  "main": "dist/lib/index.js",
10
11
  "module": "dist/lib/index.mjs",