@mxfb/tools 0.0.37 → 0.0.38
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/index.js +6 -0
- package/package.json +1 -1
- package/utils/agnostic/_WIP_tennis/index.d.ts +2 -0
- package/utils/agnostic/_WIP_tennis/index.js +1 -0
- package/utils/agnostic/is-in-enum/index.d.ts +1 -1
- package/utils/agnostic/is-in-enum/index.js +1 -1
- package/utils/agnostic/record-format/index.d.ts +11 -6
- package/utils/agnostic/record-format/index.js +1 -1
- package/utils/agnostic/string-normalize-indent/index.d.ts +1 -0
- package/utils/agnostic/string-normalize-indent/index.js +3 -0
- package/utils/node/mxfb-cli-config/index.d.ts +19 -0
- package/utils/node/mxfb-cli-config/index.js +2 -0
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Comp from './components/Comp/index.js'
|
|
2
|
+
import * as wipTennis from './utils/agnostic/_WIP_tennis/index.js'
|
|
2
3
|
import * as absoluteModulo from './utils/agnostic/absolute-modulo/index.js'
|
|
3
4
|
import * as array from './utils/agnostic/array/index.js'
|
|
4
5
|
import * as assert from './utils/agnostic/assert/index.js'
|
|
@@ -34,6 +35,7 @@ import * as selectorToElement from './utils/agnostic/selector-to-element/index.j
|
|
|
34
35
|
import * as silentLog from './utils/agnostic/silent-log/index.js'
|
|
35
36
|
import * as strToNodes from './utils/agnostic/str-to-nodes/index.js'
|
|
36
37
|
import * as stringMatches from './utils/agnostic/string-matches/index.js'
|
|
38
|
+
import * as stringNormalizeIndent from './utils/agnostic/string-normalize-indent/index.js'
|
|
37
39
|
import * as throttleDebounce from './utils/agnostic/throttle-debounce/index.js'
|
|
38
40
|
import * as toAlphanum from './utils/agnostic/to-alphanum/index.js'
|
|
39
41
|
import * as transition from './utils/agnostic/transition/index.js'
|
|
@@ -43,9 +45,11 @@ import * as getCurrentDownlink from './utils/browser/get-current-downlink/index.
|
|
|
43
45
|
import * as getNodeAncestors from './utils/browser/get-node-ancestors/index.js'
|
|
44
46
|
import * as isInDirectory from './utils/node/is-in-directory/index.js'
|
|
45
47
|
import * as listSubpaths from './utils/node/list-subpaths/index.js'
|
|
48
|
+
import * as mxfbCliConfig from './utils/node/mxfb-cli-config/index.js'
|
|
46
49
|
import * as processExit from './utils/node/process-exit/index.js'
|
|
47
50
|
import * as readWriteFile from './utils/node/read-write-file/index.js'
|
|
48
51
|
export { Comp }
|
|
52
|
+
export { wipTennis }
|
|
49
53
|
export { absoluteModulo }
|
|
50
54
|
export { array }
|
|
51
55
|
export { assert }
|
|
@@ -81,6 +85,7 @@ export { selectorToElement }
|
|
|
81
85
|
export { silentLog }
|
|
82
86
|
export { strToNodes }
|
|
83
87
|
export { stringMatches }
|
|
88
|
+
export { stringNormalizeIndent }
|
|
84
89
|
export { throttleDebounce }
|
|
85
90
|
export { toAlphanum }
|
|
86
91
|
export { transition }
|
|
@@ -90,5 +95,6 @@ export { getCurrentDownlink }
|
|
|
90
95
|
export { getNodeAncestors }
|
|
91
96
|
export { isInDirectory }
|
|
92
97
|
export { listSubpaths }
|
|
98
|
+
export { mxfbCliConfig }
|
|
93
99
|
export { processExit }
|
|
94
100
|
export { readWriteFile }
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i;(f=>{function s(S){let _=[0,0];return S.forEach(e=>{if(_.includes(5))return;let r=e?0:1,t=e?1:0,n=_[r],o=_[t];if(!(o===5||n===5)){if(o===4&&n===3){_[t]=3;return}if(o===3&&n===4){_[r]=5;return}if(n===3){_[r]=5;return}_[r]++}}),_}function a(S){let[_,e]=S;return _===5?!0:e===5?!1:null}function d(S){let _=[0,0],e=!1;return S.forEach(r=>{if(e||_.includes(7))return;let[t,n]=_;if(t>=6&&n<5||n<=6&&t<5)return;let o=s(r),c=a(o);if(c===!0){_[0]++;return}if(c===!1){_[1]++;return}e=!0}),_}})(i||={});export{i as Tennis};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function isInEnum<E extends
|
|
1
|
+
export default function isInEnum<E extends Record<string, string | number>>(enumObj: E, value: string | number): value is E[keyof E];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function l(s,n){let t=Object.keys(s),c=Object.values(s).filter(e=>typeof e=="number");return t.filter(e=>!c.includes(parseInt(e,10))).map(e=>s[e]).includes(n)}export{l as default};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
type
|
|
2
|
-
type
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export type FormatKey<Input extends {} = any> = keyof Input | string;
|
|
2
|
+
export type InputValue<Input extends {}, Key extends FormatKey<Input>> = Input extends Record<Key, infer V> ? V : undefined;
|
|
3
|
+
export type FormatterFunc<I, O> = (val: I) => O | Promise<O>;
|
|
4
|
+
export type Format<Input extends {} = any> = {
|
|
5
|
+
[Key in FormatKey<Input>]: FormatterFunc<InputValue<Input, Key>, any>;
|
|
6
|
+
};
|
|
7
|
+
export type UnwrapPromise<PromiseOrNot> = PromiseOrNot extends Promise<infer Resolved> ? Resolved : PromiseOrNot;
|
|
8
|
+
export type Formatted<F extends Format<{}>> = {
|
|
9
|
+
[Key in keyof F]: UnwrapPromise<ReturnType<F[Key]>>;
|
|
10
|
+
};
|
|
11
|
+
export default function recordFormat<I extends {}, F extends Format<I>>(input: I, format: F): Promise<Formatted<F>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
async function
|
|
1
|
+
async function a(o,n){let t={};for(let e in n){let r=n[e];typeof r=="function"?t[e]=await r(o[e]):t[e]=r}return t}export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function stringNormalizeIndent(input: string, indentLevel?: number): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Config = {
|
|
2
|
+
mxfb_projects_sync?: {
|
|
3
|
+
lm_path?: string;
|
|
4
|
+
mxfb_path?: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export declare const emptyConfigObj: Config;
|
|
8
|
+
export declare function createConfigFile(force?: boolean): Promise<true | Error>;
|
|
9
|
+
declare const deletionSecurityPhrase = "THIS IS A DESTRUCTIVE AND DEFINITIVE ACTION";
|
|
10
|
+
export declare function deleteConfigDir(security: typeof deletionSecurityPhrase): Promise<true | Error>;
|
|
11
|
+
export declare function deleteConfigFile(security: typeof deletionSecurityPhrase): Promise<true | Error>;
|
|
12
|
+
export declare function ensureConfigFile(): Promise<true | Error>;
|
|
13
|
+
export declare function getConfigFile(): Promise<string | Error>;
|
|
14
|
+
export declare function validateConfigObj(configObj: any): configObj is Config;
|
|
15
|
+
export declare function parseConfigFile(fileContents: string): Config | Error;
|
|
16
|
+
export declare function getConfig(create?: boolean): Promise<Config | Error>;
|
|
17
|
+
export type ConfigUpdater = Partial<Config> | ((curr: Config) => Config);
|
|
18
|
+
export declare function updateConfig(updater: ConfigUpdater, create?: boolean): Promise<true | Error>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import u from"node:os";import{promises as n}from"node:fs";import a from"node:path";var g=u.homedir(),f=a.join(g,".config/mxfb-cli"),o=a.join(f,"config.json"),p={};async function y(t=!1){await n.mkdir(f,{recursive:!0});try{if(await n.stat(o),t===!0)throw"create anyway";return!0}catch{try{return await n.writeFile(o,`${JSON.stringify(p,null,2)}
|
|
2
|
+
`,{encoding:"utf-8"}),!0}catch(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(`${e}`)}}}var s="THIS IS A DESTRUCTIVE AND DEFINITIVE ACTION";async function P(t){return t!==s?new Error("You must provide the security phrase"):(await n.rm(f,{recursive:!0,force:!0}),!0)}async function b(t){return t!==s?new Error("You must provide the security phrase"):(await n.rm(f),!0)}async function l(){try{return await n.stat(o),!0}catch{try{let r=await y();if(r instanceof Error)throw r;return!0}catch(r){return r instanceof Error?r:typeof r=="string"?new Error(r):new Error(`${r}`)}}}async function E(){try{return await n.readFile(o,{encoding:"utf-8"})}catch(t){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error(`${t}`)}}function w(t){return!0}function m(t){try{let r=JSON.parse(t);if(!w(r))throw new Error(`Invalid config file shape: ${t}`);return r}catch(r){return r instanceof Error?r:typeof r=="string"?new Error(r):new Error(`${r}`)}}async function C(t=!1){if(t){let i=await l();if(i!==!0)return i}let r=await E();if(r instanceof Error)return r;let e=m(r);return e instanceof Error,e}async function F(t,r=!1){let e=await C(r);if(e instanceof Error)return e;let i=typeof t=="function"?t(e):{...e,...t},c=JSON.stringify(i,null,2);return await n.writeFile(o,c,{encoding:"utf-8"}),!0}export{y as createConfigFile,P as deleteConfigDir,b as deleteConfigFile,p as emptyConfigObj,l as ensureConfigFile,C as getConfig,E as getConfigFile,m as parseConfigFile,F as updateConfig,w as validateConfigObj};
|