@design-edito/cli 0.0.74 → 0.0.76

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.
@@ -1,3 +1,4 @@
1
1
  cli
2
2
  make-template
3
- tree
3
+ tree
4
+ upgrade
@@ -1 +1 @@
1
- 0.0.74
1
+ 0.0.76
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import l from"node:process";import{promises as i,existsSync as j}from"node:fs";import x from"node:url";import t from"node:path";import{spawn as w}from"node:child_process";import{program as d}from"commander";import y from"prompts";import{Files as f}from"@design-edito/tools/node/files/index.js";var k=x.fileURLToPath(import.meta.url),h=t.dirname(k),p=l.cwd();d.name("@design-edito/make-template").description("Generate in cwd a project template");d.command("express").description("make express.js + typescript project structure").action(N);d.command("html").description("make simple html project structure").action(S);d.command("react").description("make react + typescript project structure").action(b);d.parse(l.argv);async function S(){let o=t.join(h,"assets/html");if(!j(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=t.join(p,"html-template");await i.cp(o,n,{recursive:!0})}async function b(){let o=t.join(h,"assets/react");if(!j(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=t.join(p,"react-template");await i.cp(o,n,{recursive:!0});let{projectName:s}=await y({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),u=t.join(n,"package.json");await f.readWrite(u,r=>{let e=typeof r=="string"?r:r.toString(),a=JSON.parse(e);delete a.name;let m={name:s,...a};return`${JSON.stringify(m,null,2)}
3
- `},{encoding:"utf-8"});let g=w(`cd ${n} && npm i`,{stdio:"inherit",shell:!0});await new Promise((r,e)=>{g.on("exit",()=>r(!0)),g.on("error",()=>e(!1))});let c=t.join(p,s);await i.rename(n,c),await i.rename(t.join(c,"gitignore"),t.join(c,".gitignore"))}async function N(){let o=t.join(h,"assets/express");if(!j(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=t.join(p,"express-template");await i.cp(o,n,{recursive:!0});let{projectName:s}=await y({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),u=t.join(n,"package.json");await f.readWrite(u,e=>{let a=typeof e=="string"?e:e.toString(),m=JSON.parse(a);delete m.name;let P={name:s,...m};return`${JSON.stringify(P,null,2)}
4
- `},{encoding:"utf-8"});let g=t.join(n,"src/bin/start.ts");await f.readWrite(g,e=>(typeof e=="string"?e:e.toString()).replace("<<@mxfb/cli----replace-with-name>>",s),{encoding:"utf-8"});let c=w(`cd ${n} && npm i`,{stdio:"inherit",shell:!0});await new Promise((e,a)=>{c.on("exit",()=>e(!0)),c.on("error",()=>a(!1))});let r=t.join(p,s);await i.rename(n,r),await i.rename(t.join(r,"gitignore"),t.join(r,".gitignore"))}
2
+ import l from"node:process";import{promises as i,existsSync as j}from"node:fs";import P from"node:url";import t from"node:path";import{spawn as w}from"node:child_process";import{program as d}from"commander";import x from"prompts";import{Files as f}from"@design-edito/tools/node/files/index.js";var k=P.fileURLToPath(import.meta.url),h=t.dirname(k),p=l.cwd();d.name("@design-edito/make-template").description("Generate in cwd a project template");d.command("express").description("make express.js + typescript project structure").action(N);d.command("html").description("make simple html project structure").action(S);d.command("react").description("make react + typescript project structure").action(b);d.parse(l.argv);async function S(){let o=t.join(h,"assets/html");if(!j(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=t.join(p,"html-template");await i.cp(o,n,{recursive:!0})}async function b(){let o=t.join(h,"assets/react");if(!j(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=t.join(p,"react-template");await i.cp(o,n,{recursive:!0});let{projectName:s}=await x({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),u=t.join(n,"package.json");await f.readWrite(u,r=>{let e=typeof r=="string"?r:r.toString(),a=JSON.parse(e);delete a.name;let m={name:s,...a};return`${JSON.stringify(m,null,2)}
3
+ `},{encoding:"utf-8"});let g=w(`cd ${n} && npm i`,{stdio:"inherit",shell:!0});await new Promise((r,e)=>{g.on("exit",()=>r(!0)),g.on("error",()=>e(!1))});let c=t.join(p,s);await i.rename(n,c),await i.rename(t.join(c,"gitignore"),t.join(c,".gitignore"))}async function N(){let o=t.join(h,"assets/express");if(!j(o))return console.error(`Could not find the template to copy at ${o}`),l.exit(1);let n=t.join(p,"express-template");await i.cp(o,n,{recursive:!0});let{projectName:s}=await x({name:"projectName",message:"Project name ? (for package.json name field)",type:"text"}),u=t.join(n,"package.json");await f.readWrite(u,e=>{let a=typeof e=="string"?e:e.toString(),m=JSON.parse(a);delete m.name;let y={name:s,...m};return`${JSON.stringify(y,null,2)}
4
+ `},{encoding:"utf-8"});let g=t.join(n,"src/index.ts");await f.readWrite(g,e=>(typeof e=="string"?e:e.toString()).replace("<<@mxfb/cli----replace-with-name>>",s),{encoding:"utf-8"});let c=w(`cd ${n} && npm i`,{stdio:"inherit",shell:!0});await new Promise((e,a)=>{c.on("exit",()=>e(!0)),c.on("error",()=>a(!1))});let r=t.join(p,s);await i.rename(n,r),await i.rename(t.join(r,"gitignore"),t.join(r,".gitignore"))}
5
5
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/make-template/index.ts"],
4
- "sourcesContent": ["import process from 'node:process'\nimport { promises as fs, existsSync } from 'node:fs'\nimport url from 'node:url'\nimport path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport { program } from 'commander'\nimport prompts from 'prompts'\nimport { Files } from '@design-edito/tools/node/files/index.js'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\nconst CWD = process.cwd()\n\nprogram\n .name('@design-edito/make-template')\n .description('Generate in cwd a project template')\n\nprogram\n .command('express')\n .description('make express.js + typescript project structure')\n .action(makeExpress)\n\nprogram\n .command('html')\n .description('make simple html project structure')\n .action(makeHtml)\n\nprogram\n .command('react')\n .description('make react + typescript project structure')\n .action(makeReact)\n\nprogram.parse(process.argv)\n\nasync function makeHtml () {\n const htmlTemplatePath = path.join(__dirname, 'assets/html')\n if (!existsSync(htmlTemplatePath)) {\n console.error(`Could not find the template to copy at ${htmlTemplatePath}`)\n return process.exit(1)\n }\n const targetPath = path.join(CWD, 'html-template')\n await fs.cp(htmlTemplatePath, targetPath, { recursive: true })\n}\n\nasync function makeReact () {\n const reactTemplatePath = path.join(__dirname, 'assets/react')\n if (!existsSync(reactTemplatePath)) {\n console.error(`Could not find the template to copy at ${reactTemplatePath}`)\n return process.exit(1)\n }\n const defaultTargetPath = path.join(CWD, 'react-template')\n \n // Copy\n await fs.cp(reactTemplatePath, defaultTargetPath, { recursive: true })\n const { projectName } = await prompts({\n name: 'projectName',\n message: 'Project name ? (for package.json name field)',\n type: 'text'\n })\n \n // Custom project name\n const packageJsonPath = path.join(defaultTargetPath, 'package.json')\n await Files.readWrite(packageJsonPath, rawContent => {\n const content = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n const contentObj = JSON.parse(content) as Record<string, string>\n delete contentObj.name\n const newContentObj = {\n name: projectName,\n ...contentObj\n }\n return `${JSON.stringify(newContentObj, null, 2)}\\n`\n }, { encoding: 'utf-8' })\n \n // Install deps\n const npmISubprocess = spawn(`cd ${defaultTargetPath} && npm i`, { stdio: 'inherit', shell: true })\n await new Promise((resolve, reject) => {\n npmISubprocess.on('exit', () => resolve(true))\n npmISubprocess.on('error', () => reject(false))\n })\n\n // Rename project\n const targetPath = path.join(CWD, projectName)\n await fs.rename(defaultTargetPath, targetPath)\n\n // Rename gitignore\n await fs.rename(\n path.join(targetPath, 'gitignore'),\n path.join(targetPath, '.gitignore')\n )\n}\n\nasync function makeExpress () {\n const expressTemplatePath = path.join(__dirname, 'assets/express')\n if (!existsSync(expressTemplatePath)) {\n console.error(`Could not find the template to copy at ${expressTemplatePath}`)\n return process.exit(1)\n }\n const defaultTargetPath = path.join(CWD, 'express-template')\n \n // Copy\n await fs.cp(expressTemplatePath, defaultTargetPath, { recursive: true })\n const { projectName } = await prompts({\n name: 'projectName',\n message: 'Project name ? (for package.json name field)',\n type: 'text'\n })\n \n // Custom project name in package.json\n const packageJsonPath = path.join(defaultTargetPath, 'package.json')\n await Files.readWrite(packageJsonPath, rawContent => {\n const content = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n const contentObj = JSON.parse(content) as Record<string, string>\n delete contentObj.name\n const newContentObj = {\n name: projectName,\n ...contentObj\n }\n return `${JSON.stringify(newContentObj, null, 2)}\\n`\n }, { encoding: 'utf-8' })\n\n // Custom project name in src/bin/start.ts\n const binStartTsPath = path.join(defaultTargetPath, 'src/bin/start.ts')\n await Files.readWrite(binStartTsPath, rawContent => {\n const originalContent = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n const updatedContent = originalContent.replace('<<@mxfb/cli----replace-with-name>>', projectName)\n return updatedContent\n }, { encoding: 'utf-8' })\n \n // Install deps\n const npmISubprocess = spawn(`cd ${defaultTargetPath} && npm i`, { stdio: 'inherit', shell: true })\n await new Promise((resolve, reject) => {\n npmISubprocess.on('exit', () => resolve(true))\n npmISubprocess.on('error', () => reject(false))\n })\n\n // Rename project\n const targetPath = path.join(CWD, projectName)\n await fs.rename(defaultTargetPath, targetPath)\n\n // Rename gitignore\n await fs.rename(\n path.join(targetPath, 'gitignore'),\n path.join(targetPath, '.gitignore')\n )\n}\n"],
5
- "mappings": "AAAA,OAAOA,MAAa,eACpB,OAAS,YAAYC,EAAI,cAAAC,MAAkB,UAC3C,OAAOC,MAAS,WAChB,OAAOC,MAAU,YACjB,OAAS,SAAAC,MAAa,qBACtB,OAAS,WAAAC,MAAe,YACxB,OAAOC,MAAa,UACpB,OAAS,SAAAC,MAAa,0CAEtB,IAAMC,EAAaN,EAAI,cAAc,YAAY,GAAG,EAC9CO,EAAYN,EAAK,QAAQK,CAAU,EACnCE,EAAMX,EAAQ,IAAI,EAExBM,EACG,KAAK,6BAA6B,EAClC,YAAY,oCAAoC,EAEnDA,EACG,QAAQ,SAAS,EACjB,YAAY,gDAAgD,EAC5D,OAAOM,CAAW,EAErBN,EACG,QAAQ,MAAM,EACd,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,GACe,QAAQ,qCAAsCF,CAAW,EAE/F,CAAE,SAAU,OAAQ,CAAC,EAGxB,IAAMM,EAAiBpB,EAAM,MAAMa,CAAiB,YAAa,CAAE,MAAO,UAAW,MAAO,EAAK,CAAC,EAClG,MAAM,IAAI,QAAQ,CAACQ,EAASC,IAAW,CACrCF,EAAe,GAAG,OAAQ,IAAMC,EAAQ,EAAI,CAAC,EAC7CD,EAAe,GAAG,QAAS,IAAME,EAAO,EAAK,CAAC,CAChD,CAAC,EAGD,IAAMX,EAAaZ,EAAK,KAAKO,EAAKQ,CAAW,EAC7C,MAAMlB,EAAG,OAAOiB,EAAmBF,CAAU,EAG7C,MAAMf,EAAG,OACPG,EAAK,KAAKY,EAAY,WAAW,EACjCZ,EAAK,KAAKY,EAAY,YAAY,CACpC,CACF",
4
+ "sourcesContent": ["import process from 'node:process'\nimport { promises as fs, existsSync } from 'node:fs'\nimport url from 'node:url'\nimport path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport { program } from 'commander'\nimport prompts from 'prompts'\nimport { Files } from '@design-edito/tools/node/files/index.js'\n\nconst __filename = url.fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\nconst CWD = process.cwd()\n\nprogram\n .name('@design-edito/make-template')\n .description('Generate in cwd a project template')\n\nprogram\n .command('express')\n .description('make express.js + typescript project structure')\n .action(makeExpress)\n\nprogram\n .command('html')\n .description('make simple html project structure')\n .action(makeHtml)\n\nprogram\n .command('react')\n .description('make react + typescript project structure')\n .action(makeReact)\n\nprogram.parse(process.argv)\n\nasync function makeHtml () {\n const htmlTemplatePath = path.join(__dirname, 'assets/html')\n if (!existsSync(htmlTemplatePath)) {\n console.error(`Could not find the template to copy at ${htmlTemplatePath}`)\n return process.exit(1)\n }\n const targetPath = path.join(CWD, 'html-template')\n await fs.cp(htmlTemplatePath, targetPath, { recursive: true })\n}\n\nasync function makeReact () {\n const reactTemplatePath = path.join(__dirname, 'assets/react')\n if (!existsSync(reactTemplatePath)) {\n console.error(`Could not find the template to copy at ${reactTemplatePath}`)\n return process.exit(1)\n }\n const defaultTargetPath = path.join(CWD, 'react-template')\n \n // Copy\n await fs.cp(reactTemplatePath, defaultTargetPath, { recursive: true })\n const { projectName } = await prompts({\n name: 'projectName',\n message: 'Project name ? (for package.json name field)',\n type: 'text'\n })\n \n // Custom project name\n const packageJsonPath = path.join(defaultTargetPath, 'package.json')\n await Files.readWrite(packageJsonPath, rawContent => {\n const content = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n const contentObj = JSON.parse(content) as Record<string, string>\n delete contentObj.name\n const newContentObj = {\n name: projectName,\n ...contentObj\n }\n return `${JSON.stringify(newContentObj, null, 2)}\\n`\n }, { encoding: 'utf-8' })\n \n // Install deps\n const npmISubprocess = spawn(`cd ${defaultTargetPath} && npm i`, { stdio: 'inherit', shell: true })\n await new Promise((resolve, reject) => {\n npmISubprocess.on('exit', () => resolve(true))\n npmISubprocess.on('error', () => reject(false))\n })\n\n // Rename project\n const targetPath = path.join(CWD, projectName)\n await fs.rename(defaultTargetPath, targetPath)\n\n // Rename gitignore\n await fs.rename(\n path.join(targetPath, 'gitignore'),\n path.join(targetPath, '.gitignore')\n )\n}\n\nasync function makeExpress () {\n const expressTemplatePath = path.join(__dirname, 'assets/express')\n if (!existsSync(expressTemplatePath)) {\n console.error(`Could not find the template to copy at ${expressTemplatePath}`)\n return process.exit(1)\n }\n const defaultTargetPath = path.join(CWD, 'express-template')\n \n // Copy\n await fs.cp(expressTemplatePath, defaultTargetPath, { recursive: true })\n const { projectName } = await prompts({\n name: 'projectName',\n message: 'Project name ? (for package.json name field)',\n type: 'text'\n })\n \n // Custom project name in package.json\n const packageJsonPath = path.join(defaultTargetPath, 'package.json')\n await Files.readWrite(packageJsonPath, rawContent => {\n const content = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n const contentObj = JSON.parse(content) as Record<string, string>\n delete contentObj.name\n const newContentObj = {\n name: projectName,\n ...contentObj\n }\n return `${JSON.stringify(newContentObj, null, 2)}\\n`\n }, { encoding: 'utf-8' })\n\n // Custom project name in src/index.ts\n const binStartTsPath = path.join(defaultTargetPath, 'src/index.ts')\n await Files.readWrite(binStartTsPath, rawContent => {\n const originalContent = typeof rawContent === 'string'\n ? rawContent\n : rawContent.toString()\n const updatedContent = originalContent.replace('<<@mxfb/cli----replace-with-name>>', projectName)\n return updatedContent\n }, { encoding: 'utf-8' })\n \n // Install deps\n const npmISubprocess = spawn(`cd ${defaultTargetPath} && npm i`, { stdio: 'inherit', shell: true })\n await new Promise((resolve, reject) => {\n npmISubprocess.on('exit', () => resolve(true))\n npmISubprocess.on('error', () => reject(false))\n })\n\n // Rename project\n const targetPath = path.join(CWD, projectName)\n await fs.rename(defaultTargetPath, targetPath)\n\n // Rename gitignore\n await fs.rename(\n path.join(targetPath, 'gitignore'),\n path.join(targetPath, '.gitignore')\n )\n}\n"],
5
+ "mappings": "AAAA,OAAOA,MAAa,eACpB,OAAS,YAAYC,EAAI,cAAAC,MAAkB,UAC3C,OAAOC,MAAS,WAChB,OAAOC,MAAU,YACjB,OAAS,SAAAC,MAAa,qBACtB,OAAS,WAAAC,MAAe,YACxB,OAAOC,MAAa,UACpB,OAAS,SAAAC,MAAa,0CAEtB,IAAMC,EAAaN,EAAI,cAAc,YAAY,GAAG,EAC9CO,EAAYN,EAAK,QAAQK,CAAU,EACnCE,EAAMX,EAAQ,IAAI,EAExBM,EACG,KAAK,6BAA6B,EAClC,YAAY,oCAAoC,EAEnDA,EACG,QAAQ,SAAS,EACjB,YAAY,gDAAgD,EAC5D,OAAOM,CAAW,EAErBN,EACG,QAAQ,MAAM,EACd,YAAY,oCAAoC,EAChD,OAAOO,CAAQ,EAElBP,EACG,QAAQ,OAAO,EACf,YAAY,2CAA2C,EACvD,OAAOQ,CAAS,EAEnBR,EAAQ,MAAMN,EAAQ,IAAI,EAE1B,eAAea,GAAY,CACzB,IAAME,EAAmBX,EAAK,KAAKM,EAAW,aAAa,EAC3D,GAAI,CAACR,EA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,EAAQ,EAAI,CAAC,EAC7CD,EAAe,GAAG,QAAS,IAAME,EAAO,EAAK,CAAC,CAChD,CAAC,EAGD,IAAMX,EAAaZ,EAAK,KAAKO,EAAKQ,CAAW,EAC7C,MAAMlB,EAAG,OAAOiB,EAAmBF,CAAU,EAG7C,MAAMf,EAAG,OACPG,EAAK,KAAKY,EAAY,WAAW,EACjCZ,EAAK,KAAKY,EAAY,YAAY,CACpC,CACF",
6
6
  "names": ["process", "fs", "existsSync", "url", "path", "spawn", "program", "prompts", "Files", "__filename", "__dirname", "CWD", "makeExpress", "makeHtml", "makeReact", "htmlTemplatePath", "targetPath", "reactTemplatePath", "defaultTargetPath", "projectName", "packageJsonPath", "rawContent", "content", "contentObj", "newContentObj", "npmISubprocess", "resolve", "reject", "expressTemplatePath", "binStartTsPath"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design-edito/cli",
3
- "version": "0.0.74",
3
+ "version": "0.0.76",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",
@@ -12,22 +12,23 @@
12
12
  "main": "index.js",
13
13
  "module": "index.js",
14
14
  "bin": {
15
- "make-template": "./make-template/index.js",
16
15
  "cli": "./cli/index.js",
17
- "tree": "./tree/index.js"
16
+ "make-template": "./make-template/index.js",
17
+ "tree": "./tree/index.js",
18
+ "upgrade": "./upgrade/index.js"
18
19
  },
19
20
  "dependencies": {
20
- "@design-edito/tools": "^0.1.7",
21
+ "@design-edito/tools": "^0.1.8",
21
22
  "commander": "^12.1.0",
22
23
  "prompts": "^2.4.2"
23
24
  },
24
25
  "devDependencies": {
25
- "@types/node": "^22.1.0",
26
+ "@types/node": "^22.5.5",
26
27
  "@types/prompts": "^2.4.9",
27
28
  "@types/semver": "^7.5.8",
28
- "esbuild": "^0.23.0",
29
+ "esbuild": "^0.23.1",
29
30
  "semver": "^7.6.3",
30
- "simple-git": "^3.25.0",
31
- "typescript": "^5.5.4"
31
+ "simple-git": "^3.26.0",
32
+ "typescript": "^5.6.2"
32
33
  }
33
34
  }
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import{spawn as i}from"node:child_process";import o from"node:process";import{program as n}from"commander";import a from"prompts";import{Logs as e}from"@design-edito/tools/agnostic/misc/logs/index.js";n.name("@design-edito/upgrade").description("Upgrades @design-edito/cli to the latest version available").action(async()=>{console.log(e.styles.title("Global upgrade of @design-edito/cli")),console.log(e.styles.info(`
3
+ Currently installed NPM packages:
4
+ `)),i("npm",["list","-g"],{stdio:"inherit"}).on("exit",async s=>{if(s!==0)return console.log(e.styles.error(`
5
+ Something went wrong while listing the globally installed NPM packages. Aborting.`)),o.exit(s);let{proceedUpgrade:l}=await a({name:"proceedUpgrade",type:"confirm",message:"You may be prompted for your sudo password to complete the installation. Do you want to continue?"});if(l!==!0)return console.log(e.styles.error(`
6
+ Aborting.`)),o.exit(1);console.log("");let r=i("sudo",["npm","i","-g","@design-edito/cli"],{stdio:"inherit"});console.log(e.styles.important(`Installing @design-edito/cli globally...
7
+ `)),r.on("exit",t=>{t===0?console.log(e.styles.success(`
8
+ @design-edito/cli has been successfully installed globally.
9
+ `)):(console.error(e.styles.error(`
10
+ Installation failed. Please check your permissions and try again.
11
+ `)),o.exit(t))})})});n.parse(o.argv);
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/upgrade/index.ts"],
4
+ "sourcesContent": ["import { spawn } from 'node:child_process'\nimport process from 'node:process'\nimport { program } from 'commander'\nimport prompts from 'prompts'\nimport { Logs } from '@design-edito/tools/agnostic/misc/logs/index.js'\n\nprogram\n .name('@design-edito/upgrade')\n .description('Upgrades @design-edito/cli to the latest version available')\n .action(async () => {\n console.log(Logs.styles.title('Global upgrade of @design-edito/cli'))\n console.log(Logs.styles.info('\\nCurrently installed NPM packages:\\n'))\n const child1 = spawn('npm', ['list', '-g'], { stdio: 'inherit' })\n child1.on('exit', async code => {\n if (code !== 0) {\n console.log(Logs.styles.error('\\nSomething went wrong while listing the globally installed NPM packages. Aborting.'))\n return process.exit(code)\n }\n const { proceedUpgrade } = await prompts({\n name: 'proceedUpgrade',\n type: 'confirm',\n message: 'You may be prompted for your sudo password to complete the installation. Do you want to continue?'\n })\n if (proceedUpgrade !== true) {\n console.log(Logs.styles.error('\\nAborting.'))\n return process.exit(1)\n }\n console.log('')\n const child2 = spawn('sudo', ['npm', 'i', '-g', '@design-edito/cli'], { stdio: 'inherit' })\n console.log(Logs.styles.important('Installing @design-edito/cli globally...\\n'))\n child2.on('exit', code => {\n if (code === 0) console.log(Logs.styles.success('\\n@design-edito/cli has been successfully installed globally.\\n'))\n else {\n console.error(Logs.styles.error('\\nInstallation failed. Please check your permissions and try again.\\n'))\n process.exit(code) \n }\n })\n })\n })\n\nprogram.parse(process.argv)\n"],
5
+ "mappings": "AAAA,OAAS,SAAAA,MAAa,qBACtB,OAAOC,MAAa,eACpB,OAAS,WAAAC,MAAe,YACxB,OAAOC,MAAa,UACpB,OAAS,QAAAC,MAAY,kDAErBF,EACG,KAAK,uBAAuB,EAC5B,YAAY,4DAA4D,EACxE,OAAO,SAAY,CAClB,QAAQ,IAAIE,EAAK,OAAO,MAAM,qCAAqC,CAAC,EACpE,QAAQ,IAAIA,EAAK,OAAO,KAAK;AAAA;AAAA,CAAuC,CAAC,EACtDJ,EAAM,MAAO,CAAC,OAAQ,IAAI,EAAG,CAAE,MAAO,SAAU,CAAC,EACzD,GAAG,OAAQ,MAAMK,GAAQ,CAC9B,GAAIA,IAAS,EACX,eAAQ,IAAID,EAAK,OAAO,MAAM;AAAA,kFAAqF,CAAC,EAC7GH,EAAQ,KAAKI,CAAI,EAE1B,GAAM,CAAE,eAAAC,CAAe,EAAI,MAAMH,EAAQ,CACvC,KAAM,iBACN,KAAM,UACN,QAAS,mGACX,CAAC,EACD,GAAIG,IAAmB,GACrB,eAAQ,IAAIF,EAAK,OAAO,MAAM;AAAA,UAAa,CAAC,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