@mxfb/cli 0.2.0 → 1.0.2
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/package.json +13 -21
- package/scrape-tumblr/index.js +5 -0
- package/scrape-tumblr/index.js.map +7 -0
- package/make-calendar/index.js +0 -8
- package/make-calendar/index.js.map +0 -7
- package/mfcli/assets/list.txt +0 -5
- package/mfcli/assets/version.txt +0 -1
- package/mfcli/index.js +0 -5
- package/mfcli/index.js.map +0 -7
- package/mxfb-projects-sync/assets/main.sh +0 -211
- package/mxfb-projects-sync/index.js +0 -6
- package/mxfb-projects-sync/index.js.map +0 -7
- package/term-glossary/index.js +0 -32
- package/term-glossary/index.js.map +0 -7
- package/tumblr-crawler/index.js +0 -1184
- package/tumblr-crawler/index.js.map +0 -7
package/mfcli/assets/list.txt
DELETED
package/mfcli/assets/version.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.2.0
|
package/mfcli/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import m from"node:process";import{promises as l}from"node:fs";import h from"node:url";import r from"node:path";import{spawn as g}from"node:child_process";import{program as n}from"commander";var v=h.fileURLToPath(import.meta.url),a=r.dirname(v);n.name("@mxfb/cli").description("The home of @mxfb/cli's project").option("-v, --version","output the current version").action(async t=>"version"in t?await p():n.help());n.command("list").description("list all the available commands").action(b);n.command("version").description("print current version of the package").action(p);var w=await c();w.forEach(t=>{n.command(t,{hidden:!0}).allowUnknownOption(!0).action(async(...i)=>{let[o,e,s,...d]=m.argv;if(s===void 0)return n.help();if(!(await c()).includes(s))return n.help();let u=r.join(a,"../",s,"index.js");g(u,d,{stdio:"inherit"}).on("error",f=>console.error(`Failed to start subprogram '${s}':`,f))})});n.parse(m.argv);async function c(){let t=r.join(a,"assets/list.txt");return(await l.readFile(t,{encoding:"utf-8"})).split(`
|
|
3
|
-
`).map(o=>o.trim())}async function b(){let i=(await c()).map(o=>{let e=Object.assign(new Array(24).fill(" "),o.split("")).join("");return o==="cli"?`${e} # npx @mxfb/cli help`:`${e} # npx @mxfb/cli ${o} help`}).join(`
|
|
4
|
-
`);console.log(i)}async function p(){let t=r.join(a,"assets/version.txt"),i=await l.readFile(t,{encoding:"utf-8"});console.log(i)}
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
package/mfcli/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/mfcli/index.ts"],
|
|
4
|
-
"sourcesContent": ["import process from 'node:process'\nimport { promises as fs } from 'node:fs'\nimport url from 'node:url'\nimport path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport { program } from 'commander'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\nprogram\n .name('@mxfb/cli')\n .description('The home of @mxfb/cli\\'s project')\n .option('-v, --version', 'output the current version')\n .action(async options => 'version' in options\n ? await printVersion()\n : program.help())\n \nprogram\n .command('list')\n .description('list all the available commands')\n .action(printCommands)\n\nprogram\n .command('version')\n .description('print current version of the package')\n .action(printVersion)\n\nconst subCommands = await listCommands()\nsubCommands.forEach(subCommand => {\n program\n .command(subCommand, { hidden: true })\n .allowUnknownOption(true)\n .action(async (...args) => {\n const [_nodePath, _thisPath, targetCommand, ...forwardedArgs] = process.argv\n if (targetCommand === undefined) return program.help()\n const commandsList = await listCommands()\n if (!commandsList.includes(targetCommand)) return program.help()\n const subprogramPath = path.join(__dirname, '../', targetCommand, 'index.js')\n const subprocess = spawn(subprogramPath, forwardedArgs, { stdio: 'inherit' })\n subprocess.on('error', err => console.error(`Failed to start subprogram '${targetCommand}':`, err))\n })\n})\n\nprogram.parse(process.argv)\n\nasync function listCommands () {\n const listFilePath = path.join(__dirname, 'assets/list.txt')\n const list = await fs.readFile(listFilePath, { encoding: 'utf-8' })\n return list.split('\\n').map(e => e.trim())\n}\n\nasync function printCommands () {\n const list = await listCommands()\n const output = list\n .map(c => {\n const twentyFourCharName = Object.assign(\n new Array(24).fill(' ') as string[],\n c.split('') as string[]\n ).join('')\n if (c === 'cli') return `${twentyFourCharName} # npx @mxfb/cli help`\n return `${twentyFourCharName} # npx @mxfb/cli ${c} help`\n })\n .join('\\n')\n console.log(output)\n return;\n}\n\nasync function printVersion () {\n const versionFilePath = path.join(__dirname, 'assets/version.txt')\n const version = await fs.readFile(versionFilePath, { encoding: 'utf-8' })\n console.log(version)\n return;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAOA,MAAa,eACpB,OAAS,YAAYC,MAAU,UAC/B,OAAOC,MAAS,WAChB,OAAOC,MAAU,YACjB,OAAS,SAAAC,MAAa,qBACtB,OAAS,WAAAC,MAAe,YAExB,IAAMC,EAAaJ,EAAI,cAAc,YAAY,GAAG,EAC9CK,EAAYJ,EAAK,QAAQG,CAAU,EAEzCD,EACG,KAAK,WAAW,EAChB,YAAY,iCAAkC,EAC9C,OAAO,gBAAiB,4BAA4B,EACpD,OAAO,MAAMG,GAAW,YAAaA,EAClC,MAAMC,EAAa,EACnBJ,EAAQ,KAAK,CAAC,EAEpBA,EACG,QAAQ,MAAM,EACd,YAAY,iCAAiC,EAC7C,OAAOK,CAAa,EAEvBL,EACG,QAAQ,SAAS,EACjB,YAAY,sCAAsC,EAClD,OAAOI,CAAY,EAEtB,IAAME,EAAc,MAAMC,EAAa,EACvCD,EAAY,QAAQE,GAAc,CAChCR,EACG,QAAQQ,EAAY,CAAE,OAAQ,EAAK,CAAC,EACpC,mBAAmB,EAAI,EACvB,OAAO,SAAUC,IAAS,CACzB,GAAM,CAACC,EAAWC,EAAWC,EAAe,GAAGC,CAAa,EAAIlB,EAAQ,KACxE,GAAIiB,IAAkB,OAAW,OAAOZ,EAAQ,KAAK,EAErD,GAAI,EADiB,MAAMO,EAAa,GACtB,SAASK,CAAa,EAAG,OAAOZ,EAAQ,KAAK,EAC/D,IAAMc,EAAiBhB,EAAK,KAAKI,EAAW,MAAOU,EAAe,UAAU,EACzDb,EAAMe,EAAgBD,EAAe,CAAE,MAAO,SAAU,CAAC,EACjE,GAAG,QAASE,GAAO,QAAQ,MAAM,+BAA+BH,CAAa,KAAMG,CAAG,CAAC,CACpG,CAAC,CACL,CAAC,EAEDf,EAAQ,MAAML,EAAQ,IAAI,EAE1B,eAAeY,GAAgB,CAC7B,IAAMS,EAAelB,EAAK,KAAKI,EAAW,iBAAiB,EAE3D,OADa,MAAMN,EAAG,SAASoB,EAAc,CAAE,SAAU,OAAQ,CAAC,GACtD,MAAM;AAAA,CAAI,EAAE,IAAIC,GAAKA,EAAE,KAAK,CAAC,CAC3C,CAEA,eAAeZ,GAAiB,CAE9B,IAAMa,GADO,MAAMX,EAAa,GAE7B,IAAIY,GAAK,CACR,IAAMC,EAAqB,OAAO,OAChC,IAAI,MAAM,EAAE,EAAE,KAAK,GAAG,EACtBD,EAAE,MAAM,EAAE,CACZ,EAAE,KAAK,EAAE,EACT,OAAIA,IAAM,MAAc,GAAGC,CAAkB,wBACtC,GAAGA,CAAkB,oBAAoBD,CAAC,OACnD,CAAC,EACA,KAAK;AAAA,CAAI,EACZ,QAAQ,IAAID,CAAM,CAEpB,CAEA,eAAed,GAAgB,CAC7B,IAAMiB,EAAkBvB,EAAK,KAAKI,EAAW,oBAAoB,EAC3DoB,EAAU,MAAM1B,EAAG,SAASyB,EAAiB,CAAE,SAAU,OAAQ,CAAC,EACxE,QAAQ,IAAIC,CAAO,CAErB",
|
|
6
|
-
"names": ["process", "fs", "url", "path", "spawn", "program", "__filename", "__dirname", "options", "printVersion", "printCommands", "subCommands", "listCommands", "subCommand", "args", "_nodePath", "_thisPath", "targetCommand", "forwardedArgs", "subprogramPath", "err", "listFilePath", "e", "output", "c", "twentyFourCharName", "versionFilePath", "version"]
|
|
7
|
-
}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
if [ "$#" -ne 2 ]; then
|
|
4
|
-
echo "2 arguments expected Usage: $0 <lemonde_path> <mxfb_path>"
|
|
5
|
-
exit 1
|
|
6
|
-
fi
|
|
7
|
-
|
|
8
|
-
LMDIRPATH="$1"
|
|
9
|
-
MXFBDIRPATH="$2"
|
|
10
|
-
|
|
11
|
-
function bold () {
|
|
12
|
-
echo "\033[1m$1\033[m"
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function black_on_white() {
|
|
16
|
-
echo "\033[7m $1 \033[0m"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function throw () {
|
|
20
|
-
if [[ -z "$1" ]]; then
|
|
21
|
-
exit 1
|
|
22
|
-
fi
|
|
23
|
-
echo "$(bold "Error: $1")"
|
|
24
|
-
exit 1
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function relative () {
|
|
28
|
-
if [[ -z "$1" ]]; then
|
|
29
|
-
throw "Missing arguments. Usage: relative <path>"
|
|
30
|
-
fi
|
|
31
|
-
(cd "$1" && pwd) | sed "s|^$HOME/||"
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function prompt_continue () {
|
|
35
|
-
read -p "$(bold "Continue?") (y/n) " cont
|
|
36
|
-
if [[ "$cont" != "y" ]]; then
|
|
37
|
-
echo ""
|
|
38
|
-
echo $(bold "Bye.")
|
|
39
|
-
echo ""
|
|
40
|
-
exit 0
|
|
41
|
-
else
|
|
42
|
-
echo "\n"
|
|
43
|
-
fi
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function git_status () {
|
|
47
|
-
if [[ -z "$1" ]]; then
|
|
48
|
-
throw "Missing arguments. Usage: git_status <path>"
|
|
49
|
-
fi
|
|
50
|
-
echo "$(bold "$(black_on_white "Checking git status in $(relative "$1")...")")"
|
|
51
|
-
echo "\n"
|
|
52
|
-
prompt_continue
|
|
53
|
-
cd $1
|
|
54
|
-
git status
|
|
55
|
-
echo "\n"
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function git_log () {
|
|
59
|
-
if [[ -z "$1" ]]; then
|
|
60
|
-
throw "Missing arguments. Usage: git_status <path>"
|
|
61
|
-
fi
|
|
62
|
-
echo "$(bold "$(black_on_white "Logging git history in $(relative "$1")...")")"
|
|
63
|
-
echo "\n"
|
|
64
|
-
cd $1
|
|
65
|
-
git log
|
|
66
|
-
echo "\n"
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function git_pull_master () {
|
|
70
|
-
if [[ -z "$1" ]]; then
|
|
71
|
-
throw "Missing arguments. Usage: git_pull_master <path>"
|
|
72
|
-
fi
|
|
73
|
-
echo "$(bold "$(black_on_white "Pulling origin/master in $(relative "$1")...")")"
|
|
74
|
-
echo "\n"
|
|
75
|
-
prompt_continue
|
|
76
|
-
cd $1
|
|
77
|
-
git pull origin master
|
|
78
|
-
echo "\n"
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function git_push_master () {
|
|
82
|
-
if [[ -z "$1" ]]; then
|
|
83
|
-
throw "Missing arguments. Usage: git_push_master <path>"
|
|
84
|
-
fi
|
|
85
|
-
echo "$(bold "$(black_on_white "Pushing origin/master in $(relative "$1")...")")"
|
|
86
|
-
echo "\n"
|
|
87
|
-
prompt_continue
|
|
88
|
-
cd $1
|
|
89
|
-
git push origin master
|
|
90
|
-
echo "\n"
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function git_fetch_upstream_master () {
|
|
94
|
-
if [[ -z "$1" ]]; then
|
|
95
|
-
throw "Missing arguments. Usage: git_fetch_upstream_master <path>"
|
|
96
|
-
fi
|
|
97
|
-
echo "$(bold "$(black_on_white "Fetching upstream/master in $(relative "$1")...")")"
|
|
98
|
-
echo "\n"
|
|
99
|
-
prompt_continue
|
|
100
|
-
cd $1
|
|
101
|
-
git fetch upstream master
|
|
102
|
-
echo "\n"
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function git_merge_upstream_master () {
|
|
106
|
-
if [[ -z "$1" ]]; then
|
|
107
|
-
throw "Missing arguments. Usage: git_merge_upstream_master <path>"
|
|
108
|
-
fi
|
|
109
|
-
echo "$(bold "$(black_on_white "Merging upstream/master in $(relative "$1")..")")"
|
|
110
|
-
echo "\n"
|
|
111
|
-
prompt_continue
|
|
112
|
-
cd $1
|
|
113
|
-
git merge upstream/master
|
|
114
|
-
echo "\n"
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function npm_install () {
|
|
118
|
-
if [[ -z "$1" ]]; then
|
|
119
|
-
throw "Missing arguments. Usage: npm_instann <path>"
|
|
120
|
-
fi
|
|
121
|
-
echo "$(bold "$(black_on_white "Installing NPM dependencies in $(relative "$1")..")")"
|
|
122
|
-
echo "\n"
|
|
123
|
-
prompt_continue
|
|
124
|
-
cd $1
|
|
125
|
-
npm install
|
|
126
|
-
echo "\n"
|
|
127
|
-
if [[ -n "$2" ]]; then
|
|
128
|
-
echo "installing $2"
|
|
129
|
-
npm install "$2"
|
|
130
|
-
echo "\n"
|
|
131
|
-
fi
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function build () {
|
|
135
|
-
if [[ -z "$1" || -z "$2" ]]; then
|
|
136
|
-
throw "Missing arguments. Usage: build <path> <build_command>"
|
|
137
|
-
fi
|
|
138
|
-
echo "$(bold "$(black_on_white "Building $(relative "$1")..")")"
|
|
139
|
-
echo "\n"
|
|
140
|
-
prompt_continue
|
|
141
|
-
cd $1
|
|
142
|
-
npm run $2
|
|
143
|
-
echo "\n"
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function publish () {
|
|
147
|
-
if [[ -z "$1" ]]; then
|
|
148
|
-
throw "Missing arguments. Usage: npm_instann <path>"
|
|
149
|
-
fi
|
|
150
|
-
cd $1
|
|
151
|
-
read -p "$(bold "$(black_on_white "Do you want to publish to NPM ?")") (y/n) " cont
|
|
152
|
-
echo "\n"
|
|
153
|
-
if [[ "$cont" == "y" ]]; then
|
|
154
|
-
read -p "Enter OTP : " otp
|
|
155
|
-
if [[ "$otp" == "-" ]]; then
|
|
156
|
-
echo "\n"
|
|
157
|
-
return
|
|
158
|
-
fi
|
|
159
|
-
if [[ ${#otp} -eq 6 ]]; then
|
|
160
|
-
OTP=$otp npm publish
|
|
161
|
-
git_push_master "$1"
|
|
162
|
-
echo "\n"
|
|
163
|
-
else
|
|
164
|
-
throw "Invalid OTP. OTP must be 6 characters long."
|
|
165
|
-
fi
|
|
166
|
-
fi
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
# INIT
|
|
170
|
-
echo "\n"
|
|
171
|
-
|
|
172
|
-
# LM TOOLS
|
|
173
|
-
git_status "$LMDIRPATH/lm-tools"
|
|
174
|
-
git_pull_master "$LMDIRPATH/lm-tools"
|
|
175
|
-
npm_install "$LMDIRPATH/lm-tools"
|
|
176
|
-
build "$LMDIRPATH/lm-tools" "build:src"
|
|
177
|
-
git_status "$LMDIRPATH/lm-tools"
|
|
178
|
-
publish "$LMDIRPATH/lm-tools"
|
|
179
|
-
|
|
180
|
-
# LM CLI
|
|
181
|
-
git_status "$LMDIRPATH/lm-cli"
|
|
182
|
-
git_pull_master "$LMDIRPATH/lm-cli"
|
|
183
|
-
npm_install "$LMDIRPATH/lm-cli" "@design-edito/tools@latest"
|
|
184
|
-
build "$LMDIRPATH/lm-cli" "build:src"
|
|
185
|
-
git_status "$LMDIRPATH/lm-cli"
|
|
186
|
-
publish "$LMDIRPATH/lm-cli"
|
|
187
|
-
|
|
188
|
-
# MXFB TOOLS
|
|
189
|
-
git_status "$MXFBDIRPATH/tools"
|
|
190
|
-
git_pull_master "$MXFBDIRPATH/tools"
|
|
191
|
-
git_fetch_upstream_master "$MXFBDIRPATH/tools"
|
|
192
|
-
git_merge_upstream_master "$MXFBDIRPATH/tools"
|
|
193
|
-
git_status "$MXFBDIRPATH/tools"
|
|
194
|
-
git_push_master "$MXFBDIRPATH/tools"
|
|
195
|
-
npm_install "$MXFBDIRPATH/tools"
|
|
196
|
-
build "$MXFBDIRPATH/tools" "build:src"
|
|
197
|
-
publish "$MXFBDIRPATH/tools"
|
|
198
|
-
|
|
199
|
-
# MXFB CLI
|
|
200
|
-
git_status "$MXFBDIRPATH/cli"
|
|
201
|
-
git_pull_master "$MXFBDIRPATH/cli"
|
|
202
|
-
git_fetch_upstream_master "$MXFBDIRPATH/cli"
|
|
203
|
-
git_merge_upstream_master "$MXFBDIRPATH/cli"
|
|
204
|
-
git_status "$MXFBDIRPATH/cli"
|
|
205
|
-
git_push_master "$MXFBDIRPATH/cli"
|
|
206
|
-
npm_install "$MXFBDIRPATH/cli" "@mxfb/tools@latest"
|
|
207
|
-
build "$MXFBDIRPATH/cli" "build:src"
|
|
208
|
-
publish "$MXFBDIRPATH/cli"
|
|
209
|
-
|
|
210
|
-
# END
|
|
211
|
-
echo "$(bold "Everything done. Bye.")\n"
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import l from"node:process";import I from"node:url";import h from"node:path";import L from"node:os";import{program as v}from"commander";import u from"prompts";import $ from"node:os";import{promises as s}from"node:fs";import y from"node:path";var j=$.homedir(),E=y.join(j,".config/mxfb-cli"),f=y.join(E,"config.json"),F={};async function S(t=!1){await s.mkdir(E,{recursive:!0});try{if(await s.stat(f),t===!0)throw"create anyway";return!0}catch{try{return await s.writeFile(f,`${JSON.stringify(F,null,2)}
|
|
3
|
-
`,{encoding:"utf-8"}),!0}catch(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(`${e}`)}}}async function _(){try{return await s.stat(f),!0}catch{try{let r=await S();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 M(){try{return await s.readFile(f,{encoding:"utf-8"})}catch(t){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error(`${t}`)}}function O(t){return!0}function D(t){try{let r=JSON.parse(t);if(!O(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 p(t=!1){if(t){let o=await _();if(o!==!0)return o}let r=await M();if(r instanceof Error)return r;let e=D(r);return e instanceof Error,e}async function x(t,r=!1){let e=await p(r);if(e instanceof Error)return e;let o=typeof t=="function"?t(e):{...e,...t},c=JSON.stringify(o,null,2);return await s.writeFile(f,c,{encoding:"utf-8"}),!0}import{spawn as N}from"node:child_process";var T=I.fileURLToPath(import.meta.url),A=h.dirname(T),b=l.cwd();v.name("@mxfb/mxfb-projects-sync").description("Keep in sync the different git repos for mxfb/tools & mxfb/cli").argument("[lmpath]","Path for Le Monde folder").argument("[mxfbpath]","Path for Mxfb folder").action(async(t,r,e)=>{let o=await p(!0);if(o instanceof Error)throw o;let{mxfb_projects_sync:{lm_path:c,mxfb_path:g}={}}=o,i="";if(t!==void 0)i=m(`${t}`);else{let{promptsLmPath:n}=await u({type:"text",name:"promptsLmPath",message:`Path to Le Monde directory (absolute or relative to ${b})`,initial:c??""});i=m(`${n}`)}let a="";if(r!==void 0)a=m(`${r}`);else{let{promptsMxfbPath:n}=await u({type:"text",name:"promptsMxfbPath",message:`Path to Mxfb directory (absolute or relative to ${b})`,initial:g??""});a=m(`${n}`)}console.log("Le Monde:",i),console.log("Mxfb: ",a);let{pathsAreOk:C}=await u({type:"confirm",name:"pathsAreOk",message:"Continue using those paths?"});if(C!==!0&&(console.log(`
|
|
4
|
-
Bye.
|
|
5
|
-
`),l.exit(0)),i!==c||a!==g){let{savePaths:n}=await u({type:"confirm",name:"savePaths",message:"Do you want to save those paths for the next time ?"});if(n===!0){let w=await x(P=>({...P,mxfb_projects_sync:{lm_path:i,mxfb_path:a}}),!0);if(w instanceof Error)throw w;console.log("Saved.")}}let d=N("sh",[h.join(A,"./assets/main.sh"),i,a],{stdio:"inherit"});d.on("error",n=>console.error(`Error: ${n.message}`)),d.on("close",n=>console.error(`main.sh exited with code ${n}`))});v.parse(l.argv);function m(t){return t.startsWith("~/")?h.join(L.homedir(),t.slice(2)):t}
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/mxfb-projects-sync/index.ts", "../../node_modules/@mxfb/tools/node/mxfb-cli-config/index.js"],
|
|
4
|
-
"sourcesContent": ["import process from 'node:process'\nimport url from 'node:url'\nimport path from 'node:path'\nimport os from 'node:os'\nimport { program } from 'commander'\nimport prompts from 'prompts'\nimport { getConfig, updateConfig } from '@mxfb/tools/node/mxfb-cli-config/index.js'\nimport { spawn } from 'node:child_process'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\nconst CWD = process.cwd()\n\nprogram\n .name('@mxfb/mxfb-projects-sync')\n .description('Keep in sync the different git repos for mxfb/tools & mxfb/cli')\n .argument('[lmpath]', 'Path for Le Monde folder')\n .argument('[mxfbpath]', 'Path for Mxfb folder')\n .action(async (_lmpath, _mxfbpath, options) => {\n const config = await getConfig(true)\n if (config instanceof Error) throw config\n const { mxfb_projects_sync: {\n lm_path: configLmPath,\n mxfb_path: configMxfbPath\n } = {} } = config\n \n let lmPath: string = ''\n if (_lmpath !== undefined) { lmPath = resolveHome(`${_lmpath}`) }\n else {\n const { promptsLmPath } = await prompts({\n type: 'text',\n name: 'promptsLmPath',\n message: `Path to Le Monde directory (absolute or relative to ${CWD})`,\n initial: configLmPath ?? ''\n })\n lmPath = resolveHome(`${promptsLmPath}`)\n }\n \n let mxfbPath: string = ''\n if (_mxfbpath !== undefined) { mxfbPath = resolveHome(`${_mxfbpath}`) }\n else {\n const { promptsMxfbPath } = await prompts({\n type: 'text',\n name: 'promptsMxfbPath',\n message: `Path to Mxfb directory (absolute or relative to ${CWD})`,\n initial: configMxfbPath ?? ''\n })\n mxfbPath = resolveHome(`${promptsMxfbPath}`)\n }\n\n console.log('Le Monde:', lmPath)\n console.log('Mxfb: ', mxfbPath)\n const { pathsAreOk } = await prompts({\n type: 'confirm',\n name: 'pathsAreOk',\n message: 'Continue using those paths?'\n })\n if (pathsAreOk !== true) {\n console.log('\\nBye.\\n')\n process.exit(0)\n }\n if (lmPath !== configLmPath || mxfbPath !== configMxfbPath) {\n const { savePaths } = await prompts({\n type: 'confirm',\n name: 'savePaths',\n message: 'Do you want to save those paths for the next time ?'\n })\n if (savePaths === true) {\n const updated = await updateConfig(curr => ({\n ...curr,\n mxfb_projects_sync: {\n lm_path: lmPath,\n mxfb_path: mxfbPath\n }\n }), true)\n if (updated instanceof Error) throw updated\n console.log('Saved.')\n }\n }\n \n const shellScriptExecution = spawn('sh', [path.join(__dirname, './assets/main.sh'), lmPath, mxfbPath], { stdio: 'inherit' })\n shellScriptExecution.on('error', err => console.error(`Error: ${err.message}`))\n shellScriptExecution.on('close', code => console.error(`main.sh exited with code ${code}`))\n })\n\nprogram.parse(process.argv)\n\nfunction resolveHome (filePath: string) {\n if (filePath.startsWith('~/')) return path.join(os.homedir(), filePath.slice(2))\n return filePath\n}\n\n", "// src/node/mxfb-cli-config/index.ts\nimport os from \"node:os\";\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nvar homeDirPath = os.homedir();\nvar mxfbConfigDirPath = path.join(homeDirPath, \".config/mxfb-cli\");\nvar mxfbConfigFilePath = path.join(mxfbConfigDirPath, \"config.json\");\nvar emptyConfigObj = {};\nasync function createConfigFile(force = false) {\n await fs.mkdir(mxfbConfigDirPath, { recursive: true });\n try {\n await fs.stat(mxfbConfigFilePath);\n if (force === true) throw \"create anyway\";\n return true;\n } catch (err) {\n try {\n await fs.writeFile(\n mxfbConfigFilePath,\n `${JSON.stringify(emptyConfigObj, null, 2)}\n`,\n { encoding: \"utf-8\" }\n );\n return true;\n } catch (err2) {\n if (err2 instanceof Error) return err2;\n if (typeof err2 === \"string\") return new Error(err2);\n return new Error(`${err2}`);\n }\n }\n}\nvar deletionSecurityPhrase = \"THIS IS A DESTRUCTIVE AND DEFINITIVE ACTION\";\nasync function deleteConfigDir(security) {\n if (security !== deletionSecurityPhrase) return new Error(\"You must provide the security phrase\");\n await fs.rm(mxfbConfigDirPath, { recursive: true, force: true });\n return true;\n}\nasync function deleteConfigFile(security) {\n if (security !== deletionSecurityPhrase) return new Error(\"You must provide the security phrase\");\n await fs.rm(mxfbConfigDirPath);\n return true;\n}\nasync function ensureConfigFile() {\n try {\n await fs.stat(mxfbConfigFilePath);\n return true;\n } catch (err) {\n try {\n const created = await createConfigFile();\n if (created instanceof Error) throw created;\n return true;\n } catch (err2) {\n if (err2 instanceof Error) return err2;\n if (typeof err2 === \"string\") return new Error(err2);\n return new Error(`${err2}`);\n }\n }\n}\nasync function getConfigFile() {\n try {\n const fileContents = await fs.readFile(mxfbConfigFilePath, { encoding: \"utf-8\" });\n return fileContents;\n } catch (err) {\n if (err instanceof Error) return err;\n if (typeof err === \"string\") return new Error(err);\n return new Error(`${err}`);\n }\n}\nfunction validateConfigObj(configObj) {\n return true;\n}\nfunction parseConfigFile(fileContents) {\n try {\n const parsed = JSON.parse(fileContents);\n const validated = validateConfigObj(parsed);\n if (!validated) throw new Error(`Invalid config file shape: ${fileContents}`);\n return parsed;\n } catch (err) {\n if (err instanceof Error) return err;\n if (typeof err === \"string\") return new Error(err);\n return new Error(`${err}`);\n }\n}\nasync function getConfig(create = false) {\n if (create) {\n const created = await ensureConfigFile();\n if (created !== true) return created;\n }\n const configStr = await getConfigFile();\n if (configStr instanceof Error) return configStr;\n const parsed = parseConfigFile(configStr);\n if (parsed instanceof Error) return parsed;\n return parsed;\n}\nasync function updateConfig(updater, create = false) {\n const currentConfig = await getConfig(create);\n if (currentConfig instanceof Error) return currentConfig;\n const updatedConfig = typeof updater === \"function\" ? updater(currentConfig) : { ...currentConfig, ...updater };\n const stringified = JSON.stringify(updatedConfig, null, 2);\n await fs.writeFile(mxfbConfigFilePath, stringified, { encoding: \"utf-8\" });\n return true;\n}\nexport {\n createConfigFile,\n deleteConfigDir,\n deleteConfigFile,\n emptyConfigObj,\n ensureConfigFile,\n getConfig,\n getConfigFile,\n parseConfigFile,\n updateConfig,\n validateConfigObj\n};\n"],
|
|
5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MAAMC,EAAaC,IAAS,CAC1C,GAAGA,EACH,mBAAoB,CAClB,QAASV,EACT,UAAWI,CACb,CACF,GAAI,EAAI,EACR,GAAII,aAAmB,MAAO,MAAMA,EACpC,QAAQ,IAAI,QAAQ,CACtB,CACF,CAEA,IAAMG,EAAuB1B,EAAM,KAAM,CAACI,EAAK,KAAKD,EAAW,kBAAkB,EAAGY,EAAQI,CAAQ,EAAG,CAAE,MAAO,SAAU,CAAC,EAC3HO,EAAqB,GAAG,QAASC,GAAO,QAAQ,MAAM,UAAUA,EAAI,OAAO,EAAE,CAAC,EAC9ED,EAAqB,GAAG,QAASE,GAAQ,QAAQ,MAAM,4BAA4BA,CAAI,EAAE,CAAC,CAC5F,CAAC,EAEHrB,EAAQ,MAAMD,EAAQ,IAAI,EAE1B,SAASU,EAAaa,EAAkB,CACtC,OAAIA,EAAS,WAAW,IAAI,EAAUzB,EAAK,KAAK0B,EAAG,QAAQ,EAAGD,EAAS,MAAM,CAAC,CAAC,EACxEA,CACT",
|
|
6
|
-
"names": ["process", "url", "path", "os", "program", "prompts", "os", "fs", "path", "homeDirPath", "mxfbConfigDirPath", "mxfbConfigFilePath", "emptyConfigObj", "createConfigFile", "force", "err2", "ensureConfigFile", "fs", "mxfbConfigFilePath", "created", "createConfigFile", "err2", "getConfigFile", "err", "validateConfigObj", "configObj", "parseConfigFile", "fileContents", "parsed", "getConfig", "create", "configStr", "updateConfig", "updater", "currentConfig", "updatedConfig", "stringified", "spawn", "__filename", "url", "__dirname", "path", "CWD", "process", "program", "_lmpath", "_mxfbpath", "options", "config", "getConfig", "configLmPath", "configMxfbPath", "lmPath", "resolveHome", "promptsLmPath", "prompts", "mxfbPath", "promptsMxfbPath", "pathsAreOk", "savePaths", "updated", "updateConfig", "curr", "shellScriptExecution", "err", "code", "filePath", "os"]
|
|
7
|
-
}
|
package/term-glossary/index.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
console.log(`: <<'END'
|
|
3
|
-
|
|
4
|
-
\u2039 TERM GLOSSARY \u203A
|
|
5
|
-
|
|
6
|
-
1. git & GitHub
|
|
7
|
-
|
|
8
|
-
1.1 Forking
|
|
9
|
-
|
|
10
|
-
1.1.1 Creating the fork
|
|
11
|
-
|
|
12
|
-
1.1.2 Comparing
|
|
13
|
-
|
|
14
|
-
git fetch upstream # r\xE9cup upstream \xE0 jour
|
|
15
|
-
git status # Affiche le diff avec upstream/master
|
|
16
|
-
git log HEAD..upstream/master # log les commits de upstream/master
|
|
17
|
-
|
|
18
|
-
1.1.3 Updating
|
|
19
|
-
|
|
20
|
-
git merge upstream/master # r\xE9cup\xE8re upstream/master dans origin/master
|
|
21
|
-
git push origin master
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
2. Processes & IP
|
|
25
|
-
|
|
26
|
-
lsof -i :<port> # Liste les process utilisant le port <port>
|
|
27
|
-
ps aux | grep <processName> # Liste les process en cours en filtrant sur le nom
|
|
28
|
-
|
|
29
|
-
END
|
|
30
|
-
|
|
31
|
-
`);
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/term-glossary/index.ts"],
|
|
4
|
-
"sourcesContent": ["// [WIP] use commander\n\nconsole.log(`: <<'END'\n\n\u2039 TERM GLOSSARY \u203A\n\n1. git & GitHub\n\n 1.1 Forking\n\n 1.1.1 Creating the fork\n \n 1.1.2 Comparing\n\n git fetch upstream # r\u00E9cup upstream \u00E0 jour\n git status # Affiche le diff avec upstream/master\n git log HEAD..upstream/master # log les commits de upstream/master\n\n 1.1.3 Updating\n\n git merge upstream/master # r\u00E9cup\u00E8re upstream/master dans origin/master\n git push origin master\n\n\n2. Processes & IP\n\n lsof -i :<port> # Liste les process utilisant le port <port>\n ps aux | grep <processName> # Liste les process en cours en filtrant sur le nom\n\nEND\n\n`)\n"],
|
|
5
|
-
"mappings": "AAEA,QAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CA6BX",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|