├── .gitignore ├── LICENSE.md ├── README-CN.md ├── README.md ├── commands └── init │ ├── README.md │ ├── __tests__ │ └── init.test.js │ ├── lib │ ├── index.js │ └── templates.js │ ├── package-lock.json │ └── package.json ├── core ├── cli │ ├── README.md │ ├── bin │ │ └── index.js │ ├── lib │ │ ├── const.js │ │ └── index.js │ ├── package-lock.json │ └── package.json └── exec │ ├── README.md │ ├── __tests__ │ └── exec.test.js │ ├── lib │ └── index.js │ ├── package-lock.json │ └── package.json ├── lerna-debug.log ├── lerna.json ├── models ├── command │ ├── README.md │ ├── __tests__ │ │ └── Command.test.js │ ├── lib │ │ └── index.js │ ├── package-lock.json │ └── package.json └── package │ ├── README.md │ ├── __tests__ │ └── package.test.js │ ├── lib │ └── index.js │ ├── package-lock.json │ └── package.json ├── package.json └── utils ├── format-path ├── README.md ├── __tests__ │ └── format-path.test.js ├── lib │ └── index.js └── package.json ├── get-npm-info ├── README.md ├── __tests__ │ └── get-npm-info.test.js ├── lib │ └── index.js ├── package-lock.json └── package.json ├── log ├── README.md ├── __tests__ │ └── log.test.js ├── lib │ └── index.js ├── package-lock.json └── package.json └── utils ├── README.md ├── __tests__ └── utils.test.js ├── lib └── index.js ├── package-lock.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | lerna-debug.log -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkTangCd/dapp-cli/e02a63020517460609b37620b89f6347af8aedbf/LICENSE.md -------------------------------------------------------------------------------- /README-CN.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkTangCd/dapp-cli/e02a63020517460609b37620b89f6347af8aedbf/README-CN.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [中文](https://github.com/MarkTangCd/dapp-cli/blob/main/README-CN.md) / English 2 |
3 | 4 |

Dapp Cli

5 |

6 | This is a terminal scaffold tool of Dapp and Smart Contract. 7 |

8 |

9 | Dapp CLI will help developers quickly build a base template of Dapp and Smart Contract project. 10 |
11 | Different project templates for various categories will be updated continuously. 12 |

13 |
14 | 15 |

16 | 17 | Version 18 | 19 | 20 | License 21 | 22 | GitHub stars 23 |

24 | 25 | ## Documentation 26 | 27 | Writing... 28 | 29 | ## Installation 30 | 31 | Install Dapp CLI. 32 | 33 | ```bash 34 | npm install -g yarn 35 | npm install -g @dapp-cli/cli 36 | ``` 37 | 38 | ## Quick Start 39 | 40 | Create workspace: 41 | 42 | ```bash 43 | dapp init 44 | ``` 45 | ![dapp-cli-flow.gif](https://s2.loli.net/2022/05/15/8rA7NolMWLZEmxF.gif) 46 | 47 | ```bash 48 | dapp -h 49 | ``` 50 | ![Help](https://s2.loli.net/2022/05/15/Wl7N8KMAdmUbRto.png) -------------------------------------------------------------------------------- /commands/init/README.md: -------------------------------------------------------------------------------- 1 | # `@dapp-cli/init` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | const init = require('@dapp-cli/init'); 9 | 10 | // TODO: DEMONSTRATE API 11 | ``` 12 | -------------------------------------------------------------------------------- /commands/init/__tests__/init.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const init = require('..'); 4 | 5 | describe('@dapp-cli/init', () => { 6 | it('needs tests'); 7 | }); 8 | -------------------------------------------------------------------------------- /commands/init/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const inquirer = require('inquirer'); 6 | const fse = require('fs-extra'); 7 | const glob = require('glob'); 8 | const ejs = require('ejs'); 9 | const semver = require('semver'); 10 | const userHome = require('user-home'); 11 | const Command = require('@dapp-cli/command'); 12 | const Package = require('@dapp-cli/package'); 13 | const log = require('@dapp-cli/log'); 14 | const { spinnerStart, sleep, execAsync } = require('@dapp-cli/utils'); 15 | const templates = require('./templates'); 16 | 17 | const TYPE_PROJECT = 'project'; 18 | const TYPE_COMPONENT = 'component'; 19 | 20 | const WHITE_COMMAND = ['npm', 'cnpm', 'yarn', 'pnpm']; 21 | 22 | class InitCommand extends Command { 23 | init() { 24 | this.projectName = this._argv[0] || ''; 25 | this.force = !!this._cmd.force; 26 | log.verbose('projectName', this.projectName); 27 | log.verbose('force', this.force); 28 | } 29 | 30 | async exec() { 31 | try { 32 | const projectInfo = await this.prepare(); 33 | if (projectInfo) { 34 | // 2. Download template 35 | log.verbose('projectInfo', projectInfo); 36 | this.projectInfo = projectInfo; 37 | await this.downloadTemplate(); 38 | // 3. Install template 39 | await this.installTemplate(); 40 | } 41 | } catch(e) { 42 | log.error(e.message); 43 | if (process.env.LOG_LEVEL === 'verbose') { 44 | console.log(e); 45 | } 46 | } 47 | } 48 | 49 | async installTemplate() { 50 | if (this.templateInfo) { 51 | await this.installNormalTemplate(); 52 | } else { 53 | throw new Error('The project template information does not exist!'); 54 | } 55 | } 56 | 57 | checkCommand(cmd) { 58 | if (WHITE_COMMAND.includes(cmd)) { 59 | return cmd; 60 | } 61 | 62 | return null; 63 | } 64 | 65 | async execCommand(command, errMsg = 'Dependency package installation failed!') { 66 | let ret; 67 | if (command && command.length > 0) { 68 | const cmd = this.checkCommand(command[0]); 69 | if (!cmd) { 70 | throw new Error('The command does not exist: ', command); 71 | } 72 | const args = command.slice(1); 73 | ret = await execAsync(cmd, args, { 74 | stdio: 'inherit', 75 | cwd: process.cwd() 76 | }); 77 | } 78 | if (ret !== 0) { 79 | throw new Error(errMsg); 80 | } 81 | return ret; 82 | } 83 | 84 | async ejsRender(options) { 85 | const dir = process.cwd(); 86 | return new Promise((resolve, reject) => { 87 | glob('**', { 88 | cwd: dir, 89 | ignore: options.ignore || '', 90 | nodir: true 91 | }, (err, files) => { 92 | if (err) { 93 | reject(err); 94 | } 95 | Promise.all(files.map(file => { 96 | const filePath = path.join(dir, file); 97 | return new Promise((resolve2, reject2) => { 98 | ejs.renderFile(filePath, this.projectInfo, {}, (err, result) => { 99 | if (err) { 100 | reject2(err); 101 | } else { 102 | fse.writeFileSync(filePath, result); 103 | resolve2(result); 104 | } 105 | }); 106 | }); 107 | })).then(() => { 108 | resolve(); 109 | }).catch(err => { 110 | reject(err); 111 | }); 112 | }); 113 | }); 114 | } 115 | 116 | async installNormalTemplate() { 117 | log.verbose('templateNpm', this.templateNpm); 118 | let spinner = spinnerStart('Template being installed'); 119 | await sleep(); 120 | try { 121 | const templatePath = path.resolve(this.templateNpm.cacheFilePath, 'template'); 122 | const targetPath = process.cwd(); 123 | fse.ensureDirSync(templatePath); 124 | fse.ensureDirSync(targetPath); 125 | fse.copySync(templatePath, targetPath); 126 | } catch(e) { 127 | throw e; 128 | } finally { 129 | spinner.stop(true); 130 | log.success('Template installed successfully.'); 131 | } 132 | const templateIgnore = this.templateInfo.ignore || []; 133 | const ignore = ['node_modules/**', ...templateIgnore]; 134 | await this.ejsRender({ ignore }); 135 | const { installCommand, startCommand } = this.templateInfo; 136 | // install 137 | await this.execCommand(installCommand); 138 | // start 139 | if (startCommand && startCommand.length > 0) { 140 | await this.execCommand(startCommand); 141 | } 142 | } 143 | 144 | async downloadTemplate() { 145 | const { projectTemplate } = this.projectInfo; 146 | const templateInfo = this.templates.find(item => item.npmName === projectTemplate); 147 | const targetPath = path.resolve(userHome, '.dapp-cli-dev', 'template'); 148 | const storeDir = path.resolve(userHome, '.dapp-cli-dev', 'template', 'node_modules'); 149 | const { npmName, version } = templateInfo; 150 | this.templateInfo = templateInfo; 151 | const templateNpm = new Package({ 152 | targetPath, 153 | storeDir, 154 | packageName: npmName, 155 | packageVersion: version 156 | }); 157 | if (! await templateNpm.exists()) { 158 | const spinner = spinnerStart('Downloading the template...'); 159 | await sleep(); 160 | try { 161 | await templateNpm.install(); 162 | } catch (e) { 163 | throw e; 164 | } finally { 165 | spinner.stop(true); 166 | if (templateNpm.exists()) { 167 | log.success('Download template successfully'); 168 | this.templateNpm = templateNpm; 169 | } 170 | } 171 | } else { 172 | const spinner = spinnerStart('Updating the template...'); 173 | await sleep(); 174 | try { 175 | await templateNpm.update(); 176 | } catch (e) { 177 | throw e; 178 | } finally { 179 | spinner.stop(true); 180 | if (templateNpm.exists()) { 181 | log.success('Update template successfully'); 182 | this.templateNpm = templateNpm; 183 | } 184 | } 185 | } 186 | } 187 | 188 | async prepare() { 189 | this.templates = templates; 190 | const localPath = process.cwd(); 191 | if(!this.isDirEmpty(localPath)) { 192 | let ifContinue = false; 193 | if (!this.force) { 194 | ifContinue = (await inquirer.prompt({ 195 | type: 'confirm', 196 | name: 'ifContinue', 197 | default: false, 198 | message: 'The current folder is not empty, does the project continue to be created?' 199 | })).ifContinue; 200 | 201 | if (!ifContinue) { 202 | return; 203 | } 204 | } 205 | 206 | if (ifContinue || this.force) { 207 | const { confirmDelete } = await inquirer.prompt({ 208 | type: 'confirm', 209 | name: 'confirmDelete', 210 | default: false, 211 | message: 'Confirm to empty the current folder?' 212 | }); 213 | if (confirmDelete) { 214 | fse.emptyDirSync(localPath); 215 | } 216 | } 217 | } 218 | return this.getProjectInfo(); 219 | } 220 | 221 | createTemplateChoice() { 222 | return templates.map(item => ({ 223 | value: item.npmName, 224 | name: item.name 225 | })); 226 | } 227 | 228 | async getProjectInfo() { 229 | function isValidName(name) { 230 | return /^[a-zA-Z]+([-][a-zA-Z][a-zA-Z0-9]*|[_][a-zA-Z][a-zA-Z0-9]*|[a-zA-Z0-9])*$/.test(name); 231 | } 232 | 233 | let projectInfo = {}; 234 | let isProjectNameValid = false; 235 | if (isValidName(this.projectName)) { 236 | isProjectNameValid = true; 237 | projectInfo.projectName = this.projectName; 238 | } 239 | const { type } = await inquirer.prompt({ 240 | type: 'list', 241 | name: 'type', 242 | message: 'Please select the initialization type', 243 | default: TYPE_PROJECT, 244 | choices: [{ 245 | name: 'Project', 246 | value: TYPE_PROJECT 247 | }, 248 | { 249 | name: 'Component', 250 | value: TYPE_COMPONENT 251 | }] 252 | }); 253 | log.verbose('type', type); 254 | this.templates = this.templates.filter(template => template.tag.includes(type)); 255 | const title = type === TYPE_PROJECT ? 'project' : 'component'; 256 | 257 | const projectNamePrompt = { 258 | type: 'input', 259 | name: 'projectName', 260 | message: `Please enter the ${title} name`, 261 | validate: function(v) { 262 | const done = this.async(); 263 | setTimeout(function () { 264 | if (!isValidName(v)) { 265 | done(`Please enter the ${title} name in the correct format`); 266 | return; 267 | } 268 | done(null, true); 269 | }, 0); 270 | }, 271 | filter: function(v) { 272 | return v; 273 | } 274 | }; 275 | const projectPrompt = []; 276 | if (!isProjectNameValid) { 277 | projectPrompt.push(projectNamePrompt); 278 | } 279 | projectPrompt.push({ 280 | type: 'input', 281 | name: 'projectVersion', 282 | message: `Please enter the ${title} version number`, 283 | default: '1.0.0', 284 | validate: function(v) { 285 | const done = this.async(); 286 | setTimeout(function () { 287 | if (!(!!semver.valid(v))) { 288 | done(`Please enter the ${title} version number in the correct format`); 289 | return; 290 | } 291 | done(null, true); 292 | }, 0); 293 | }, 294 | filter: function(v) { 295 | if (!!semver.valid(v)) { 296 | return semver.valid(v); 297 | } else { 298 | return v; 299 | } 300 | } 301 | }, { 302 | type: 'list', 303 | name: 'projectTemplate', 304 | message: `Please select a ${title} template`, 305 | choices: this.createTemplateChoice() 306 | }); 307 | if (type === TYPE_PROJECT) { 308 | const project = await inquirer.prompt(projectPrompt); 309 | projectInfo = { 310 | ...projectInfo, 311 | type, 312 | ...project 313 | } 314 | } else if (type === TYPE_COMPONENT) { 315 | const descriptionPrompt = { 316 | type: 'input', 317 | name: 'componentDescription', 318 | message: 'Please enter the component description', 319 | validate: function(v) { 320 | const done = this.async(); 321 | setTimeout(function () { 322 | if (!v) { 323 | done('Please enter the component description'); 324 | return; 325 | } 326 | done(null, true); 327 | }, 0); 328 | } 329 | }; 330 | projectPrompt.push(descriptionPrompt); 331 | const project = await inquirer.prompt(projectPrompt); 332 | projectInfo = { 333 | ...projectInfo, 334 | type, 335 | ...project 336 | } 337 | } 338 | 339 | // formattedName 340 | if (projectInfo.projectName) { 341 | projectInfo.formattedName = require('kebab-case')(projectInfo.projectName).replace(/^-/, ''); 342 | } 343 | if (projectPrompt.componentDescription) { 344 | projectInfo.description = projectInfo.componentDescription; 345 | } 346 | return projectInfo; 347 | } 348 | 349 | isDirEmpty(localPath) { 350 | let fileList = fs.readdirSync(localPath); 351 | fileList = fileList.filter(file => ( 352 | !file.startsWith('.') && ['node_modules'].indexOf(file) < 0 353 | )); 354 | return !fileList || fileList.length <= 0; 355 | } 356 | 357 | } 358 | 359 | function init(argv) { 360 | return new InitCommand(argv); 361 | } 362 | 363 | module.exports = init; 364 | module.exports.InitCommand = InitCommand; 365 | -------------------------------------------------------------------------------- /commands/init/lib/templates.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | id: 1, 4 | name: 'Dapp: Normal', 5 | npmName: 'dapp-cli-template-normal', 6 | version: 'latest', 7 | disabled: false, 8 | installCommand: ["yarn"], 9 | startCommand: [], 10 | tag: ["project"], 11 | ignore: ["**/packages/**"] 12 | }, 13 | { 14 | id: 2, 15 | name: 'Dapp: Polygon-Marketplace', 16 | npmName: 'dapp-cli-template-polygon-marketplace', 17 | version: 'latest', 18 | disabled: false, 19 | installCommand: ["yarn"], 20 | startCommand: ["yarn", "run", "dev"], 21 | tag: ["project"], 22 | ignore: [] 23 | }, 24 | { 25 | id: 3, 26 | name: 'Dapp: Moralis-Marketplace', 27 | npmName: 'dapp-cli-template-moralis-marketplace', 28 | version: 'latest', 29 | disabled: false, 30 | installCommand: ["yarn"], 31 | startCommand: [], 32 | tag: ["project"], 33 | ignore: ["**/Truffle/**"] 34 | }, 35 | { 36 | id: 4, 37 | name: 'Test-Component', 38 | npmName: 'dapp-cli-component-test', 39 | version: 'latest', 40 | disabled: false, 41 | installCommand: ["yarn"], 42 | startCommand: [], 43 | tag: ["component"], 44 | ignore: [] 45 | } 46 | ] -------------------------------------------------------------------------------- /commands/init/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/init", 3 | "version": "1.0.7", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "ansi-escapes": { 8 | "version": "4.3.2", 9 | "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", 10 | "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", 11 | "requires": { 12 | "type-fest": "^0.21.3" 13 | } 14 | }, 15 | "ansi-regex": { 16 | "version": "5.0.1", 17 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", 18 | "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" 19 | }, 20 | "ansi-styles": { 21 | "version": "4.3.0", 22 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", 23 | "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", 24 | "requires": { 25 | "color-convert": "^2.0.1" 26 | } 27 | }, 28 | "async": { 29 | "version": "3.2.3", 30 | "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", 31 | "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==" 32 | }, 33 | "balanced-match": { 34 | "version": "1.0.2", 35 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 36 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" 37 | }, 38 | "base64-js": { 39 | "version": "1.5.1", 40 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", 41 | "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" 42 | }, 43 | "bl": { 44 | "version": "4.1.0", 45 | "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", 46 | "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", 47 | "requires": { 48 | "buffer": "^5.5.0", 49 | "inherits": "^2.0.4", 50 | "readable-stream": "^3.4.0" 51 | } 52 | }, 53 | "brace-expansion": { 54 | "version": "2.0.1", 55 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", 56 | "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", 57 | "requires": { 58 | "balanced-match": "^1.0.0" 59 | } 60 | }, 61 | "buffer": { 62 | "version": "5.7.1", 63 | "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", 64 | "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", 65 | "requires": { 66 | "base64-js": "^1.3.1", 67 | "ieee754": "^1.1.13" 68 | } 69 | }, 70 | "chalk": { 71 | "version": "4.1.2", 72 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", 73 | "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", 74 | "requires": { 75 | "ansi-styles": "^4.1.0", 76 | "supports-color": "^7.1.0" 77 | } 78 | }, 79 | "chardet": { 80 | "version": "0.7.0", 81 | "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", 82 | "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" 83 | }, 84 | "cli-cursor": { 85 | "version": "3.1.0", 86 | "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", 87 | "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", 88 | "requires": { 89 | "restore-cursor": "^3.1.0" 90 | } 91 | }, 92 | "cli-spinners": { 93 | "version": "2.6.1", 94 | "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.6.1.tgz", 95 | "integrity": "sha512-x/5fWmGMnbKQAaNwN+UZlV79qBLM9JFnJuJ03gIi5whrob0xV0ofNVHy9DhwGdsMJQc2OKv0oGmLzvaqvAVv+g==" 96 | }, 97 | "cli-width": { 98 | "version": "3.0.0", 99 | "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", 100 | "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==" 101 | }, 102 | "clone": { 103 | "version": "1.0.4", 104 | "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", 105 | "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=" 106 | }, 107 | "color-convert": { 108 | "version": "2.0.1", 109 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", 110 | "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", 111 | "requires": { 112 | "color-name": "~1.1.4" 113 | } 114 | }, 115 | "color-name": { 116 | "version": "1.1.4", 117 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", 118 | "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" 119 | }, 120 | "concat-map": { 121 | "version": "0.0.1", 122 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 123 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" 124 | }, 125 | "defaults": { 126 | "version": "1.0.3", 127 | "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", 128 | "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", 129 | "requires": { 130 | "clone": "^1.0.2" 131 | } 132 | }, 133 | "ejs": { 134 | "version": "3.1.8", 135 | "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz", 136 | "integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==", 137 | "requires": { 138 | "jake": "^10.8.5" 139 | } 140 | }, 141 | "emoji-regex": { 142 | "version": "8.0.0", 143 | "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", 144 | "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" 145 | }, 146 | "escape-string-regexp": { 147 | "version": "1.0.5", 148 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", 149 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" 150 | }, 151 | "external-editor": { 152 | "version": "3.1.0", 153 | "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", 154 | "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", 155 | "requires": { 156 | "chardet": "^0.7.0", 157 | "iconv-lite": "^0.4.24", 158 | "tmp": "^0.0.33" 159 | } 160 | }, 161 | "figures": { 162 | "version": "3.2.0", 163 | "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", 164 | "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", 165 | "requires": { 166 | "escape-string-regexp": "^1.0.5" 167 | } 168 | }, 169 | "filelist": { 170 | "version": "1.0.4", 171 | "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", 172 | "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", 173 | "requires": { 174 | "minimatch": "^5.0.1" 175 | } 176 | }, 177 | "fs-extra": { 178 | "version": "10.1.0", 179 | "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", 180 | "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", 181 | "requires": { 182 | "graceful-fs": "^4.2.0", 183 | "jsonfile": "^6.0.1", 184 | "universalify": "^2.0.0" 185 | } 186 | }, 187 | "fs.realpath": { 188 | "version": "1.0.0", 189 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 190 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" 191 | }, 192 | "glob": { 193 | "version": "8.0.3", 194 | "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", 195 | "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", 196 | "requires": { 197 | "fs.realpath": "^1.0.0", 198 | "inflight": "^1.0.4", 199 | "inherits": "2", 200 | "minimatch": "^5.0.1", 201 | "once": "^1.3.0" 202 | } 203 | }, 204 | "graceful-fs": { 205 | "version": "4.2.10", 206 | "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", 207 | "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" 208 | }, 209 | "has-flag": { 210 | "version": "4.0.0", 211 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", 212 | "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" 213 | }, 214 | "iconv-lite": { 215 | "version": "0.4.24", 216 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", 217 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", 218 | "requires": { 219 | "safer-buffer": ">= 2.1.2 < 3" 220 | } 221 | }, 222 | "ieee754": { 223 | "version": "1.2.1", 224 | "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", 225 | "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" 226 | }, 227 | "inflight": { 228 | "version": "1.0.6", 229 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 230 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 231 | "requires": { 232 | "once": "^1.3.0", 233 | "wrappy": "1" 234 | } 235 | }, 236 | "inherits": { 237 | "version": "2.0.4", 238 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 239 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 240 | }, 241 | "inquirer": { 242 | "version": "8.2.4", 243 | "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.2.4.tgz", 244 | "integrity": "sha512-nn4F01dxU8VeKfq192IjLsxu0/OmMZ4Lg3xKAns148rCaXP6ntAoEkVYZThWjwON8AlzdZZi6oqnhNbxUG9hVg==", 245 | "requires": { 246 | "ansi-escapes": "^4.2.1", 247 | "chalk": "^4.1.1", 248 | "cli-cursor": "^3.1.0", 249 | "cli-width": "^3.0.0", 250 | "external-editor": "^3.0.3", 251 | "figures": "^3.0.0", 252 | "lodash": "^4.17.21", 253 | "mute-stream": "0.0.8", 254 | "ora": "^5.4.1", 255 | "run-async": "^2.4.0", 256 | "rxjs": "^7.5.5", 257 | "string-width": "^4.1.0", 258 | "strip-ansi": "^6.0.0", 259 | "through": "^2.3.6", 260 | "wrap-ansi": "^7.0.0" 261 | } 262 | }, 263 | "is-fullwidth-code-point": { 264 | "version": "3.0.0", 265 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", 266 | "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" 267 | }, 268 | "is-interactive": { 269 | "version": "1.0.0", 270 | "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", 271 | "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==" 272 | }, 273 | "is-unicode-supported": { 274 | "version": "0.1.0", 275 | "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", 276 | "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==" 277 | }, 278 | "jake": { 279 | "version": "10.8.5", 280 | "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.5.tgz", 281 | "integrity": "sha512-sVpxYeuAhWt0OTWITwT98oyV0GsXyMlXCF+3L1SuafBVUIr/uILGRB+NqwkzhgXKvoJpDIpQvqkUALgdmQsQxw==", 282 | "requires": { 283 | "async": "^3.2.3", 284 | "chalk": "^4.0.2", 285 | "filelist": "^1.0.1", 286 | "minimatch": "^3.0.4" 287 | }, 288 | "dependencies": { 289 | "brace-expansion": { 290 | "version": "1.1.11", 291 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 292 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 293 | "requires": { 294 | "balanced-match": "^1.0.0", 295 | "concat-map": "0.0.1" 296 | } 297 | }, 298 | "minimatch": { 299 | "version": "3.1.2", 300 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", 301 | "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", 302 | "requires": { 303 | "brace-expansion": "^1.1.7" 304 | } 305 | } 306 | } 307 | }, 308 | "jsonfile": { 309 | "version": "6.1.0", 310 | "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", 311 | "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", 312 | "requires": { 313 | "graceful-fs": "^4.1.6", 314 | "universalify": "^2.0.0" 315 | } 316 | }, 317 | "kebab-case": { 318 | "version": "1.0.1", 319 | "resolved": "https://registry.npmjs.org/kebab-case/-/kebab-case-1.0.1.tgz", 320 | "integrity": "sha512-txPHx6nVLhv8PHGXIlAk0nYoh894SpAqGPXNvbg2hh8spvHXIah3+vT87DLoa59nKgC6scD3u3xAuRIgiMqbfQ==" 321 | }, 322 | "lodash": { 323 | "version": "4.17.21", 324 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", 325 | "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" 326 | }, 327 | "log-symbols": { 328 | "version": "4.1.0", 329 | "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", 330 | "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", 331 | "requires": { 332 | "chalk": "^4.1.0", 333 | "is-unicode-supported": "^0.1.0" 334 | } 335 | }, 336 | "lru-cache": { 337 | "version": "6.0.0", 338 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", 339 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", 340 | "requires": { 341 | "yallist": "^4.0.0" 342 | } 343 | }, 344 | "mimic-fn": { 345 | "version": "2.1.0", 346 | "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", 347 | "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" 348 | }, 349 | "minimatch": { 350 | "version": "5.0.1", 351 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", 352 | "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", 353 | "requires": { 354 | "brace-expansion": "^2.0.1" 355 | } 356 | }, 357 | "mute-stream": { 358 | "version": "0.0.8", 359 | "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", 360 | "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" 361 | }, 362 | "once": { 363 | "version": "1.4.0", 364 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 365 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 366 | "requires": { 367 | "wrappy": "1" 368 | } 369 | }, 370 | "onetime": { 371 | "version": "5.1.2", 372 | "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", 373 | "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", 374 | "requires": { 375 | "mimic-fn": "^2.1.0" 376 | } 377 | }, 378 | "ora": { 379 | "version": "5.4.1", 380 | "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", 381 | "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", 382 | "requires": { 383 | "bl": "^4.1.0", 384 | "chalk": "^4.1.0", 385 | "cli-cursor": "^3.1.0", 386 | "cli-spinners": "^2.5.0", 387 | "is-interactive": "^1.0.0", 388 | "is-unicode-supported": "^0.1.0", 389 | "log-symbols": "^4.1.0", 390 | "strip-ansi": "^6.0.0", 391 | "wcwidth": "^1.0.1" 392 | } 393 | }, 394 | "os-homedir": { 395 | "version": "1.0.2", 396 | "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", 397 | "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" 398 | }, 399 | "os-tmpdir": { 400 | "version": "1.0.2", 401 | "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", 402 | "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" 403 | }, 404 | "readable-stream": { 405 | "version": "3.6.0", 406 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", 407 | "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", 408 | "requires": { 409 | "inherits": "^2.0.3", 410 | "string_decoder": "^1.1.1", 411 | "util-deprecate": "^1.0.1" 412 | } 413 | }, 414 | "restore-cursor": { 415 | "version": "3.1.0", 416 | "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", 417 | "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", 418 | "requires": { 419 | "onetime": "^5.1.0", 420 | "signal-exit": "^3.0.2" 421 | } 422 | }, 423 | "run-async": { 424 | "version": "2.4.1", 425 | "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", 426 | "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==" 427 | }, 428 | "rxjs": { 429 | "version": "7.5.5", 430 | "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.5.tgz", 431 | "integrity": "sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==", 432 | "requires": { 433 | "tslib": "^2.1.0" 434 | } 435 | }, 436 | "safe-buffer": { 437 | "version": "5.2.1", 438 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 439 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" 440 | }, 441 | "safer-buffer": { 442 | "version": "2.1.2", 443 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 444 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 445 | }, 446 | "semver": { 447 | "version": "7.3.7", 448 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", 449 | "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", 450 | "requires": { 451 | "lru-cache": "^6.0.0" 452 | } 453 | }, 454 | "signal-exit": { 455 | "version": "3.0.7", 456 | "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", 457 | "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" 458 | }, 459 | "string-width": { 460 | "version": "4.2.3", 461 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", 462 | "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", 463 | "requires": { 464 | "emoji-regex": "^8.0.0", 465 | "is-fullwidth-code-point": "^3.0.0", 466 | "strip-ansi": "^6.0.1" 467 | } 468 | }, 469 | "string_decoder": { 470 | "version": "1.3.0", 471 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", 472 | "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", 473 | "requires": { 474 | "safe-buffer": "~5.2.0" 475 | } 476 | }, 477 | "strip-ansi": { 478 | "version": "6.0.1", 479 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", 480 | "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", 481 | "requires": { 482 | "ansi-regex": "^5.0.1" 483 | } 484 | }, 485 | "supports-color": { 486 | "version": "7.2.0", 487 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", 488 | "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", 489 | "requires": { 490 | "has-flag": "^4.0.0" 491 | } 492 | }, 493 | "through": { 494 | "version": "2.3.8", 495 | "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", 496 | "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" 497 | }, 498 | "tmp": { 499 | "version": "0.0.33", 500 | "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", 501 | "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", 502 | "requires": { 503 | "os-tmpdir": "~1.0.2" 504 | } 505 | }, 506 | "tslib": { 507 | "version": "2.4.0", 508 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", 509 | "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" 510 | }, 511 | "type-fest": { 512 | "version": "0.21.3", 513 | "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", 514 | "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==" 515 | }, 516 | "universalify": { 517 | "version": "2.0.0", 518 | "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", 519 | "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" 520 | }, 521 | "user-home": { 522 | "version": "3.0.0", 523 | "resolved": "https://registry.npmjs.org/user-home/-/user-home-3.0.0.tgz", 524 | "integrity": "sha512-kHp9sWxeB+EVTcVytDrGLVKgVVN1LoLiIZTwCDcvYNjIu9q7tUOXZoTv0mXjmvFvUju4J9v+RkFGHdTMx8ncmQ==", 525 | "requires": { 526 | "os-homedir": "^1.0.0" 527 | } 528 | }, 529 | "util-deprecate": { 530 | "version": "1.0.2", 531 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 532 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 533 | }, 534 | "wcwidth": { 535 | "version": "1.0.1", 536 | "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", 537 | "integrity": "sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=", 538 | "requires": { 539 | "defaults": "^1.0.3" 540 | } 541 | }, 542 | "wrap-ansi": { 543 | "version": "7.0.0", 544 | "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", 545 | "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", 546 | "requires": { 547 | "ansi-styles": "^4.0.0", 548 | "string-width": "^4.1.0", 549 | "strip-ansi": "^6.0.0" 550 | } 551 | }, 552 | "wrappy": { 553 | "version": "1.0.2", 554 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 555 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" 556 | }, 557 | "yallist": { 558 | "version": "4.0.0", 559 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", 560 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" 561 | } 562 | } 563 | } 564 | -------------------------------------------------------------------------------- /commands/init/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/init", 3 | "version": "1.0.7", 4 | "description": "dapp-cli init", 5 | "author": "Mark Tang ", 6 | "homepage": "https://github.com/MarkTangCd/dapp-cli#readme", 7 | "license": "ISC", 8 | "main": "lib/index.js", 9 | "directories": { 10 | "lib": "lib", 11 | "test": "__tests__" 12 | }, 13 | "files": [ 14 | "lib" 15 | ], 16 | "publishConfig": { 17 | "access": "public" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/MarkTangCd/dapp-cli.git" 22 | }, 23 | "scripts": { 24 | "test": "echo \"Error: run tests from root\" && exit 1" 25 | }, 26 | "dependencies": { 27 | "@dapp-cli/command": "^1.0.6", 28 | "@dapp-cli/log": "^1.0.6", 29 | "@dapp-cli/package": "^1.0.6", 30 | "@dapp-cli/utils": "^1.0.6", 31 | "ejs": "^3.1.8", 32 | "fs-extra": "^10.1.0", 33 | "glob": "^8.0.3", 34 | "inquirer": "^8.2.4", 35 | "kebab-case": "^1.0.1", 36 | "semver": "^7.3.7", 37 | "user-home": "3.0.0" 38 | }, 39 | "bugs": { 40 | "url": "https://github.com/MarkTangCd/dapp-cli/issues" 41 | }, 42 | "gitHead": "822b3bfe67703d4342d440c2a78fa52f442e5aae" 43 | } 44 | -------------------------------------------------------------------------------- /core/cli/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkTangCd/dapp-cli/e02a63020517460609b37620b89f6347af8aedbf/core/cli/README.md -------------------------------------------------------------------------------- /core/cli/bin/index.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | const importLocal = require('import-local'); 4 | 5 | if (importLocal(__filename)) { 6 | require('npmlog').info('cli', 'dapp-cli local version is being used'); 7 | } else { 8 | require('../lib')(process.argv.slice(2)); 9 | } 10 | -------------------------------------------------------------------------------- /core/cli/lib/const.js: -------------------------------------------------------------------------------- 1 | const DEFAULT_CLI_HOME = '.dapp-cli'; 2 | 3 | module.exports = { 4 | DEFAULT_CLI_HOME 5 | } 6 | -------------------------------------------------------------------------------- /core/cli/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = core; 4 | 5 | const path = require('path'); 6 | const semver = require('semver'); 7 | const colors = require('colors'); 8 | const pathExists = require('path-exists').sync; 9 | const commander = require('commander'); 10 | const userHome = require('user-home'); 11 | const log = require('@dapp-cli/log'); 12 | const exec = require('@dapp-cli/exec'); 13 | 14 | const pkg = require('../package.json'); 15 | const constant = require('./const'); 16 | 17 | const program = new commander.Command(); 18 | 19 | async function core() { 20 | try { 21 | await prepare(); 22 | registerCommand(); 23 | } catch (e) { 24 | log.error(e.message); 25 | if (program.debug) { 26 | console.log(e); 27 | } 28 | } 29 | } 30 | 31 | function registerCommand() { 32 | program 33 | .name(Object.keys(pkg.bin)[0]) 34 | .usage(' [options]') 35 | .version(pkg.version) 36 | .option('-d, --debug', 'Is debug mode on?', false) 37 | .option('-tp, --targetPath ', 'Is the local debug file path specified?', ''); 38 | 39 | program 40 | .command('init [projectName]') 41 | .option('-f, --force', 'Does it force the directory to be overwritten for initialization?') 42 | .action(exec); 43 | 44 | // debug mode 45 | program.on('option:debug', function() { 46 | const options = program.opts(); 47 | if (options.debug) { 48 | process.env.LOG_LEVEL = 'verbose'; 49 | } else { 50 | process.env.LOG_LEVEL = 'info'; 51 | } 52 | log.level = process.env.LOG_LEVEL; 53 | }); 54 | 55 | // targetPath 56 | program.on('option:targetPath', function() { 57 | const options = program.opts(); 58 | process.env.CLI_TARGET_PATH = options.targetPath; 59 | }); 60 | 61 | // Listening for unknown commands 62 | program.on('command:*', function(obj) { 63 | const availableCommands = program.commands.map(cmd => cmd.name()); 64 | console.log('Unknown command:' + obj[0]); 65 | if (availableCommands.length > 0) { 66 | console.log('Available commands:' + availableCommands.join(',')); 67 | } 68 | }); 69 | 70 | program.parse(process.argv); 71 | 72 | if (program.args && program.args.length < 1) { 73 | program.outputHelp(); 74 | console.log(); 75 | } 76 | } 77 | 78 | async function prepare() { 79 | checkPkgVersion(); 80 | checkRoot(); 81 | checkUserHome(); 82 | checkEnv(); 83 | await checkGlobalUpdate(); 84 | } 85 | 86 | async function checkGlobalUpdate() { 87 | // 1. get current version no and the module name. 88 | // 2. call npm api, get all version no. 89 | // 3. compare version no. 90 | // 4. get latest version no and notice the user to update to latest version. 91 | const currentVersion = pkg.version; 92 | const npmName = pkg.name; 93 | const { getNpmSemverVersion } = require('@dapp-cli/get-npm-info'); 94 | const lastVersion = await getNpmSemverVersion(currentVersion, npmName); 95 | if (lastVersion && semver.gt(lastVersion, currentVersion)) { 96 | log.warn('Notice', colors.yellow(`Please manually update ${npmName} to the latest version ${lastVersion}.`)); 97 | } 98 | } 99 | 100 | function checkEnv() { 101 | const dotenv = require('dotenv'); 102 | const dotenvPath = path.resolve(userHome, '.env'); 103 | if (pathExists(dotenvPath)) { 104 | dotenv.config({ 105 | path: path.resolve(userHome, '.env') 106 | }); 107 | } 108 | createDefaultConfig(); 109 | } 110 | 111 | function createDefaultConfig() { 112 | const cliConfig = { 113 | home: userHome 114 | } 115 | if (process.env.CLI_HOME) { 116 | cliConfig['cliHome'] = path.join(userHome, process.env.CLI_HOME); 117 | } else { 118 | cliConfig['cliHome'] = path.join(userHome, constant.DEFAULT_CLI_HOME); 119 | } 120 | process.env.CLI_HOME_PATH = cliConfig.cliHome; 121 | } 122 | 123 | function checkUserHome() { 124 | if (!userHome || !pathExists(userHome)) { 125 | throw new Error(colors.red('The current login user\'s home directory does not exist.')); 126 | } 127 | } 128 | 129 | function checkRoot() { 130 | const rootCheck = require('root-check'); 131 | rootCheck(); 132 | } 133 | 134 | function checkPkgVersion() { 135 | log.notice('cli', pkg.version); 136 | } 137 | -------------------------------------------------------------------------------- /core/cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/cli", 3 | "version": "1.0.7", 4 | "description": "dapp-cli core", 5 | "author": "MarkTang ", 6 | "license": "ISC", 7 | "main": "", 8 | "bin": { 9 | "dapp": "bin/index.js" 10 | }, 11 | "directories": { 12 | "lib": "lib", 13 | "test": "__tests__" 14 | }, 15 | "files": [ 16 | "lib" 17 | ], 18 | "scripts": { 19 | "test": "echo \"Error: no test specified\" && exit 1" 20 | }, 21 | "dependencies": { 22 | "@dapp-cli/exec": "^1.0.6", 23 | "@dapp-cli/get-npm-info": "^1.0.6", 24 | "@dapp-cli/init": "^1.0.7", 25 | "@dapp-cli/log": "^1.0.6", 26 | "colors": "^1.4.0", 27 | "commander": "^9.2.0", 28 | "dotenv": "^16.0.0", 29 | "import-local": "^3.1.0", 30 | "npmlog": "^6.0.2", 31 | "path-exists": "4.0.0", 32 | "root-check": "1.0.0", 33 | "semver": "^7.3.7", 34 | "user-home": "^3.0.0" 35 | }, 36 | "gitHead": "822b3bfe67703d4342d440c2a78fa52f442e5aae", 37 | "publishConfig": { 38 | "access": "public" 39 | }, 40 | "keywords": [] 41 | } 42 | -------------------------------------------------------------------------------- /core/exec/README.md: -------------------------------------------------------------------------------- 1 | # `@dapp-cli/exec` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | const exec = require('@dapp-cli/exec'); 9 | 10 | // TODO: DEMONSTRATE API 11 | ``` 12 | -------------------------------------------------------------------------------- /core/exec/__tests__/exec.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const exec = require('..'); 4 | 5 | describe('@dapp-cli/exec', () => { 6 | it('needs tests'); 7 | }); 8 | -------------------------------------------------------------------------------- /core/exec/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | const Package = require('@dapp-cli/package'); 5 | const log = require('@dapp-cli/log'); 6 | const { exec: spawn } = require('@dapp-cli/utils'); 7 | 8 | const SETTINGS = { 9 | init: '@dapp-cli/init' 10 | }; 11 | 12 | const CACHE_DIR = 'dependencies'; 13 | 14 | async function exec() { 15 | let targetPath = process.env.CLI_TARGET_PATH; 16 | const homePath = process.env.CLI_HOME_PATH; 17 | let storeDir = ''; 18 | let pkg; 19 | log.verbose('targetPath', targetPath); 20 | log.verbose('homePath', homePath); 21 | 22 | const cmdObj = arguments[arguments.length - 1]; 23 | const cmdName = cmdObj.name(); 24 | const packageName = SETTINGS[cmdName]; 25 | const packageVersion = 'latest'; 26 | 27 | if (!targetPath) { 28 | targetPath = path.resolve(homePath, CACHE_DIR); // Generate cache path 29 | storeDir = path.resolve(targetPath, 'node_modules'); 30 | log.verbose('targetPath', targetPath); 31 | log.verbose('storeDir', storeDir); 32 | pkg = new Package({ 33 | targetPath, 34 | storeDir, 35 | packageName, 36 | packageVersion 37 | }); 38 | if (await pkg.exists()) { 39 | // update the package 40 | await pkg.update(); 41 | } else { 42 | // install the package 43 | await pkg.install(); 44 | } 45 | } else { 46 | pkg = new Package({ 47 | targetPath, 48 | packageName, 49 | packageVersion 50 | }); 51 | } 52 | const rootFile = pkg.getRootFilePath(); 53 | if (rootFile) { 54 | try { 55 | const args = Array.from(arguments); 56 | const cmd = args[args.length - 1]; 57 | const o = Object.create(null); 58 | Object.keys(cmd).forEach(key => { 59 | if (cmd.hasOwnProperty(key) && 60 | !key.startsWith('_') && 61 | key !== 'parent') { 62 | o[key] = cmd[key]; 63 | } 64 | }); 65 | args[args.length - 1] = o; 66 | const code = `require('${rootFile}').call(null, ${JSON.stringify(args)})`; 67 | const child = spawn('node', ['-e', code], { 68 | cwd: process.cwd(), 69 | stdio: 'inherit' 70 | }); 71 | child.on('error', error => { 72 | log.error(error.message); 73 | process.exit(1); 74 | }); 75 | child.on('exit', result => { 76 | log.verbose('Command executed successfully:' + result); 77 | process.exit(result); 78 | }); 79 | } catch(e) { 80 | log.error(e.message); 81 | } 82 | // child process 83 | } 84 | // 1. targetPath -> modulePath 85 | // 2. modulePath -> Package(npm module) 86 | // 3. Package.getRootFile(get the entry file) 87 | // 4. Package.update / Package.install 88 | 89 | } 90 | 91 | module.exports = exec; 92 | -------------------------------------------------------------------------------- /core/exec/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/exec", 3 | "version": "1.0.6", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@dapp-cli/log": { 8 | "version": "file:../../utils/log", 9 | "requires": { 10 | "npmlog": "^6.0.2" 11 | }, 12 | "dependencies": { 13 | "ansi-regex": { 14 | "version": "5.0.1", 15 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", 16 | "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" 17 | }, 18 | "aproba": { 19 | "version": "2.0.0", 20 | "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", 21 | "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==" 22 | }, 23 | "are-we-there-yet": { 24 | "version": "3.0.0", 25 | "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.0.tgz", 26 | "integrity": "sha512-0GWpv50YSOcLXaN6/FAKY3vfRbllXWV2xvfA/oKJF8pzFhWXPV+yjhJXDBbjscDYowv7Yw1A3uigpzn5iEGTyw==", 27 | "requires": { 28 | "delegates": "^1.0.0", 29 | "readable-stream": "^3.6.0" 30 | } 31 | }, 32 | "color-support": { 33 | "version": "1.1.3", 34 | "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", 35 | "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==" 36 | }, 37 | "console-control-strings": { 38 | "version": "1.1.0", 39 | "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", 40 | "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" 41 | }, 42 | "delegates": { 43 | "version": "1.0.0", 44 | "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", 45 | "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" 46 | }, 47 | "emoji-regex": { 48 | "version": "8.0.0", 49 | "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", 50 | "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" 51 | }, 52 | "gauge": { 53 | "version": "4.0.4", 54 | "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", 55 | "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", 56 | "requires": { 57 | "aproba": "^1.0.3 || ^2.0.0", 58 | "color-support": "^1.1.3", 59 | "console-control-strings": "^1.1.0", 60 | "has-unicode": "^2.0.1", 61 | "signal-exit": "^3.0.7", 62 | "string-width": "^4.2.3", 63 | "strip-ansi": "^6.0.1", 64 | "wide-align": "^1.1.5" 65 | } 66 | }, 67 | "has-unicode": { 68 | "version": "2.0.1", 69 | "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", 70 | "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" 71 | }, 72 | "inherits": { 73 | "version": "2.0.4", 74 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 75 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 76 | }, 77 | "is-fullwidth-code-point": { 78 | "version": "3.0.0", 79 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", 80 | "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" 81 | }, 82 | "npmlog": { 83 | "version": "6.0.2", 84 | "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", 85 | "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", 86 | "requires": { 87 | "are-we-there-yet": "^3.0.0", 88 | "console-control-strings": "^1.1.0", 89 | "gauge": "^4.0.3", 90 | "set-blocking": "^2.0.0" 91 | } 92 | }, 93 | "readable-stream": { 94 | "version": "3.6.0", 95 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", 96 | "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", 97 | "requires": { 98 | "inherits": "^2.0.3", 99 | "string_decoder": "^1.1.1", 100 | "util-deprecate": "^1.0.1" 101 | } 102 | }, 103 | "safe-buffer": { 104 | "version": "5.2.1", 105 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 106 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" 107 | }, 108 | "set-blocking": { 109 | "version": "2.0.0", 110 | "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", 111 | "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" 112 | }, 113 | "signal-exit": { 114 | "version": "3.0.7", 115 | "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", 116 | "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" 117 | }, 118 | "string-width": { 119 | "version": "4.2.3", 120 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", 121 | "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", 122 | "requires": { 123 | "emoji-regex": "^8.0.0", 124 | "is-fullwidth-code-point": "^3.0.0", 125 | "strip-ansi": "^6.0.1" 126 | } 127 | }, 128 | "string_decoder": { 129 | "version": "1.3.0", 130 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", 131 | "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", 132 | "requires": { 133 | "safe-buffer": "~5.2.0" 134 | } 135 | }, 136 | "strip-ansi": { 137 | "version": "6.0.1", 138 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", 139 | "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", 140 | "requires": { 141 | "ansi-regex": "^5.0.1" 142 | } 143 | }, 144 | "util-deprecate": { 145 | "version": "1.0.2", 146 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 147 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 148 | }, 149 | "wide-align": { 150 | "version": "1.1.5", 151 | "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", 152 | "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", 153 | "requires": { 154 | "string-width": "^1.0.2 || 2 || 3 || 4" 155 | } 156 | } 157 | } 158 | }, 159 | "@dapp-cli/package": { 160 | "version": "file:../../models/package" 161 | }, 162 | "@dapp-cli/utils": { 163 | "version": "file:../../utils/utils", 164 | "requires": { 165 | "cli-spinner": "^0.2.10" 166 | }, 167 | "dependencies": { 168 | "cli-spinner": { 169 | "version": "0.2.10", 170 | "resolved": "https://registry.npmjs.org/cli-spinner/-/cli-spinner-0.2.10.tgz", 171 | "integrity": "sha512-U0sSQ+JJvSLi1pAYuJykwiA8Dsr15uHEy85iCJ6A+0DjVxivr3d+N2Wjvodeg89uP5K6TswFkKBfAD7B3YSn/Q==" 172 | } 173 | } 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /core/exec/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/exec", 3 | "version": "1.0.6", 4 | "description": "dapp-cli execute package", 5 | "author": "Mark Tang ", 6 | "homepage": "https://github.com/MarkTangCd/dapp-cli#readme", 7 | "license": "ISC", 8 | "main": "lib/index.js", 9 | "directories": { 10 | "lib": "lib", 11 | "test": "__tests__" 12 | }, 13 | "files": [ 14 | "lib" 15 | ], 16 | "publishConfig": { 17 | "access": "public" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/MarkTangCd/dapp-cli.git" 22 | }, 23 | "scripts": { 24 | "test": "echo \"Error: run tests from root\" && exit 1" 25 | }, 26 | "dependencies": { 27 | "@dapp-cli/log": "^1.0.6", 28 | "@dapp-cli/package": "^1.0.6", 29 | "@dapp-cli/utils": "^1.0.6" 30 | }, 31 | "bugs": { 32 | "url": "https://github.com/MarkTangCd/dapp-cli/issues" 33 | }, 34 | "gitHead": "822b3bfe67703d4342d440c2a78fa52f442e5aae" 35 | } 36 | -------------------------------------------------------------------------------- /lerna-debug.log: -------------------------------------------------------------------------------- 1 | 54 error Error: Command failed with exit code 1: git commit -m v1.0.3 2 | 54 error On branch main 3 | 54 error Your branch is ahead of 'origin/main' by 1 commit. 4 | 54 error (use "git push" to publish your local commits) 5 | 54 error 6 | 54 error nothing to commit, working tree clean 7 | 54 error at makeError (/usr/local/lib/node_modules/pnpm-global/5/node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/error.js:60:11) 8 | 54 error at handlePromise (/usr/local/lib/node_modules/pnpm-global/5/node_modules/.pnpm/execa@5.1.1/node_modules/execa/index.js:118:26) 9 | 54 error at processTicksAndRejections (node:internal/process/task_queues:96:5) 10 | 54 error at async Promise.all (index 0) 11 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | "core/*", 4 | "commands/*", 5 | "models/*", 6 | "utils/*" 7 | ], 8 | "version": "1.0.7" 9 | } 10 | -------------------------------------------------------------------------------- /models/command/README.md: -------------------------------------------------------------------------------- 1 | # `@dapp-cli/Command` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | const command = require('@dapp-cli/Command'); 9 | 10 | // TODO: DEMONSTRATE API 11 | ``` 12 | -------------------------------------------------------------------------------- /models/command/__tests__/Command.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const command = require('..'); 4 | 5 | describe('@dapp-cli/Command', () => { 6 | it('needs tests'); 7 | }); 8 | -------------------------------------------------------------------------------- /models/command/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const log = require('@dapp-cli/log'); 4 | const semver = require('semver'); 5 | const colors = require('colors'); 6 | 7 | const LOWEST_NODE_VERSION = '12.0.0'; 8 | 9 | class Command { 10 | constructor(argv) { 11 | if (!argv) { 12 | throw new Error('The parameter cannot be empty.'); 13 | } 14 | 15 | if (!Array.isArray(argv)) { 16 | throw new Error('The parameter type must be Array.'); 17 | } 18 | 19 | if (argv.length < 1) { 20 | throw new Error('The parameter cannot be empty.'); 21 | } 22 | 23 | this._argv = argv; 24 | this.runner = new Promise((resolve, reject) => { 25 | let chain = Promise.resolve(); 26 | chain = chain.then(() => this.checkNodeVersion()); 27 | chain = chain.then(() => this.initArgs()); 28 | chain = chain.then(() => this.init()); 29 | chain = chain.then(() => this.exec()); 30 | chain.catch(err => { 31 | log.error(err.message); 32 | }); 33 | }); 34 | } 35 | 36 | initArgs() { 37 | this._cmd = this._argv[1]; 38 | this._argv = this._argv.slice(0, this._argv.length - 1); 39 | } 40 | 41 | checkNodeVersion() { 42 | // step1 get current node version no. 43 | const currentVersion = process.version; 44 | // step2 compare version no 45 | const lowestVersion = LOWEST_NODE_VERSION; 46 | if (!semver.gte(currentVersion, lowestVersion)) { 47 | throw new Error(colors.red(`dapp-cli requires Node.js version v${lowestVersion} or higher to be installed.`)); 48 | } 49 | } 50 | 51 | init() { 52 | throw new Error('The init function must implement the.'); 53 | } 54 | 55 | exec() { 56 | throw new Error('The exec function must implement the'); 57 | } 58 | } 59 | 60 | module.exports = Command; 61 | -------------------------------------------------------------------------------- /models/command/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/command", 3 | "version": "1.0.6", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@dapp-cli/log": { 8 | "version": "file:../../utils/log", 9 | "requires": { 10 | "npmlog": "^6.0.2" 11 | }, 12 | "dependencies": { 13 | "ansi-regex": { 14 | "version": "5.0.1", 15 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", 16 | "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" 17 | }, 18 | "aproba": { 19 | "version": "2.0.0", 20 | "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", 21 | "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==" 22 | }, 23 | "are-we-there-yet": { 24 | "version": "3.0.0", 25 | "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.0.tgz", 26 | "integrity": "sha512-0GWpv50YSOcLXaN6/FAKY3vfRbllXWV2xvfA/oKJF8pzFhWXPV+yjhJXDBbjscDYowv7Yw1A3uigpzn5iEGTyw==", 27 | "requires": { 28 | "delegates": "^1.0.0", 29 | "readable-stream": "^3.6.0" 30 | } 31 | }, 32 | "color-support": { 33 | "version": "1.1.3", 34 | "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", 35 | "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==" 36 | }, 37 | "console-control-strings": { 38 | "version": "1.1.0", 39 | "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", 40 | "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" 41 | }, 42 | "delegates": { 43 | "version": "1.0.0", 44 | "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", 45 | "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" 46 | }, 47 | "emoji-regex": { 48 | "version": "8.0.0", 49 | "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", 50 | "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" 51 | }, 52 | "gauge": { 53 | "version": "4.0.4", 54 | "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", 55 | "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", 56 | "requires": { 57 | "aproba": "^1.0.3 || ^2.0.0", 58 | "color-support": "^1.1.3", 59 | "console-control-strings": "^1.1.0", 60 | "has-unicode": "^2.0.1", 61 | "signal-exit": "^3.0.7", 62 | "string-width": "^4.2.3", 63 | "strip-ansi": "^6.0.1", 64 | "wide-align": "^1.1.5" 65 | } 66 | }, 67 | "has-unicode": { 68 | "version": "2.0.1", 69 | "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", 70 | "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" 71 | }, 72 | "inherits": { 73 | "version": "2.0.4", 74 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 75 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 76 | }, 77 | "is-fullwidth-code-point": { 78 | "version": "3.0.0", 79 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", 80 | "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" 81 | }, 82 | "npmlog": { 83 | "version": "6.0.2", 84 | "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", 85 | "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", 86 | "requires": { 87 | "are-we-there-yet": "^3.0.0", 88 | "console-control-strings": "^1.1.0", 89 | "gauge": "^4.0.3", 90 | "set-blocking": "^2.0.0" 91 | } 92 | }, 93 | "readable-stream": { 94 | "version": "3.6.0", 95 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", 96 | "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", 97 | "requires": { 98 | "inherits": "^2.0.3", 99 | "string_decoder": "^1.1.1", 100 | "util-deprecate": "^1.0.1" 101 | } 102 | }, 103 | "safe-buffer": { 104 | "version": "5.2.1", 105 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 106 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" 107 | }, 108 | "set-blocking": { 109 | "version": "2.0.0", 110 | "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", 111 | "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" 112 | }, 113 | "signal-exit": { 114 | "version": "3.0.7", 115 | "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", 116 | "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" 117 | }, 118 | "string-width": { 119 | "version": "4.2.3", 120 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", 121 | "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", 122 | "requires": { 123 | "emoji-regex": "^8.0.0", 124 | "is-fullwidth-code-point": "^3.0.0", 125 | "strip-ansi": "^6.0.1" 126 | } 127 | }, 128 | "string_decoder": { 129 | "version": "1.3.0", 130 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", 131 | "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", 132 | "requires": { 133 | "safe-buffer": "~5.2.0" 134 | } 135 | }, 136 | "strip-ansi": { 137 | "version": "6.0.1", 138 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", 139 | "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", 140 | "requires": { 141 | "ansi-regex": "^5.0.1" 142 | } 143 | }, 144 | "util-deprecate": { 145 | "version": "1.0.2", 146 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 147 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 148 | }, 149 | "wide-align": { 150 | "version": "1.1.5", 151 | "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", 152 | "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", 153 | "requires": { 154 | "string-width": "^1.0.2 || 2 || 3 || 4" 155 | } 156 | } 157 | } 158 | }, 159 | "@dapp-cli/utils": { 160 | "version": "file:../../utils/utils" 161 | }, 162 | "colors": { 163 | "version": "1.4.0", 164 | "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", 165 | "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==" 166 | }, 167 | "lru-cache": { 168 | "version": "6.0.0", 169 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", 170 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", 171 | "requires": { 172 | "yallist": "^4.0.0" 173 | } 174 | }, 175 | "semver": { 176 | "version": "7.3.7", 177 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", 178 | "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", 179 | "requires": { 180 | "lru-cache": "^6.0.0" 181 | } 182 | }, 183 | "yallist": { 184 | "version": "4.0.0", 185 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", 186 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /models/command/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/command", 3 | "version": "1.0.6", 4 | "description": "dapp-cli command", 5 | "author": "Mark Tang ", 6 | "homepage": "https://github.com/MarkTangCd/dapp-cli#readme", 7 | "license": "ISC", 8 | "main": "lib/index.js", 9 | "directories": { 10 | "lib": "lib", 11 | "test": "__tests__" 12 | }, 13 | "files": [ 14 | "lib" 15 | ], 16 | "publishConfig": { 17 | "access": "public" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/MarkTangCd/dapp-cli.git" 22 | }, 23 | "scripts": { 24 | "test": "echo \"Error: run tests from root\" && exit 1" 25 | }, 26 | "bugs": { 27 | "url": "https://github.com/MarkTangCd/dapp-cli/issues" 28 | }, 29 | "dependencies": { 30 | "@dapp-cli/log": "^1.0.6", 31 | "colors": "^1.4.0", 32 | "semver": "^7.3.7" 33 | }, 34 | "gitHead": "822b3bfe67703d4342d440c2a78fa52f442e5aae" 35 | } 36 | -------------------------------------------------------------------------------- /models/package/README.md: -------------------------------------------------------------------------------- 1 | # `@dapp-cli/package` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | const package = require('@dapp-cli/package'); 9 | 10 | // TODO: DEMONSTRATE API 11 | ``` 12 | -------------------------------------------------------------------------------- /models/package/__tests__/package.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const package = require('..'); 4 | 5 | describe('@dapp-cli/package', () => { 6 | it('needs tests'); 7 | }); 8 | -------------------------------------------------------------------------------- /models/package/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | const fse = require('fs-extra'); 5 | const pkgDir = require('pkg-dir').sync; 6 | const pathExists = require('path-exists').sync; 7 | const npminstall = require('npminstall'); 8 | const { isObject } = require('@dapp-cli/utils'); 9 | const formatPath = require('@dapp-cli/format-path'); 10 | const { getDefaultRegistry, getNpmLatestVersion } = require('@dapp-cli/get-npm-info'); 11 | 12 | class Package { 13 | constructor(options) { 14 | if (!options) { 15 | throw new Error('The options parameter cannot be empty.'); 16 | } 17 | if (!isObject(options)) { 18 | throw new Error('The options must be Object type.'); 19 | } 20 | // target path of the package 21 | this.targetPath = options.targetPath; 22 | // the cache path 23 | this.storeDir = options.storeDir; 24 | // name of the package 25 | this.packageName = options.packageName; 26 | // version of the package 27 | this.packageVersion = options.packageVersion; 28 | // package cache path prefix 29 | this.cacheFilePathPrefix = this.packageName.replace('/', '_') 30 | } 31 | 32 | async prepare() { 33 | if (this.storeDir && !pathExists(this.storeDir)) { 34 | fse.mkdirpSync(this.storeDir); 35 | } 36 | if (this.packageVersion === 'latest') { 37 | this.packageVersion = await getNpmLatestVersion(this.packageName); 38 | } 39 | } 40 | 41 | get cacheFilePath() { 42 | return path.resolve(this.storeDir, `_${this.cacheFilePathPrefix}@${this.packageVersion}@${this.packageName}`); 43 | } 44 | 45 | getSpecificCacheFilePath(packageVersion) { 46 | return path.resolve(this.storeDir, `_${this.cacheFilePathPrefix}@${packageVersion}@${this.packageName}`); 47 | } 48 | 49 | // Does the current package exist 50 | async exists() { 51 | if (this.storeDir) { 52 | await this.prepare(); 53 | return pathExists(this.cacheFilePath); 54 | } else { 55 | return pathExists(this.targetPath); 56 | } 57 | } 58 | 59 | async install() { 60 | await this.prepare(); 61 | return npminstall({ 62 | root: this.targetPath, 63 | storeDir: this.storeDir, 64 | registry: getDefaultRegistry(), 65 | pkgs: [ 66 | { name: this.packageName, version: this.packageVersion } 67 | ] 68 | }); 69 | } 70 | 71 | async update() { 72 | await this.prepare(); 73 | const latestPackageVersion = await getNpmLatestVersion(this.packageName); 74 | const latestFilePath = this.getSpecificCacheFilePath(latestPackageVersion); 75 | if (!pathExists(latestFilePath)) { 76 | await npminstall({ 77 | root: this.targetPath, 78 | storeDir: this.storeDir, 79 | registry: getDefaultRegistry(), 80 | pkgs: [ 81 | { name: this.packageName, version: latestPackageVersion } 82 | ] 83 | }); 84 | this.packageVersion = latestPackageVersion; 85 | } else { 86 | this.packageVersion = latestPackageVersion; 87 | } 88 | } 89 | 90 | // get the entry file path 91 | getRootFilePath() { 92 | function _getRootFile(targetPath) { 93 | const dir = pkgDir(targetPath); 94 | if (dir) { 95 | const pkgFile = require(path.resolve(dir, 'package.json')); 96 | if (pkgFile && pkgFile.main) { 97 | return formatPath(path.resolve(dir, pkgFile.main)); 98 | } 99 | } 100 | return null; 101 | } 102 | if (this.storeDir) { 103 | return _getRootFile(this.cacheFilePath); 104 | } else { 105 | return _getRootFile(this.targetPath); 106 | } 107 | } 108 | } 109 | 110 | module.exports = Package; 111 | -------------------------------------------------------------------------------- /models/package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/package", 3 | "version": "1.0.6", 4 | "description": "dapp-cli npm modules", 5 | "author": "Mark Tang ", 6 | "homepage": "https://github.com/MarkTangCd/dapp-cli#readme", 7 | "license": "ISC", 8 | "main": "lib/index.js", 9 | "directories": { 10 | "lib": "lib", 11 | "test": "__tests__" 12 | }, 13 | "files": [ 14 | "lib" 15 | ], 16 | "publishConfig": { 17 | "access": "public" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/MarkTangCd/dapp-cli.git" 22 | }, 23 | "scripts": { 24 | "test": "echo \"Error: run tests from root\" && exit 1" 25 | }, 26 | "dependencies": { 27 | "@dapp-cli/format-path": "^1.0.6", 28 | "@dapp-cli/get-npm-info": "^1.0.6", 29 | "@dapp-cli/utils": "^1.0.6", 30 | "fs-extra": "^10.1.0", 31 | "npminstall": "^6.1.0", 32 | "path-exists": "^4.0.0", 33 | "pkg-dir": "^5.0.0" 34 | }, 35 | "bugs": { 36 | "url": "https://github.com/MarkTangCd/dapp-cli/issues" 37 | }, 38 | "gitHead": "822b3bfe67703d4342d440c2a78fa52f442e5aae" 39 | } 40 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dapp-cli", 3 | "version": "1.0.2", 4 | "keywords": [ 5 | "dapp", 6 | "cli", 7 | "contract", 8 | "ethereum" 9 | ], 10 | "devDependencies": { 11 | "lerna": "^4.0.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /utils/format-path/README.md: -------------------------------------------------------------------------------- 1 | # `@dapp-cli/format-path` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | const formatPath = require('@dapp-cli/format-path'); 9 | 10 | // TODO: DEMONSTRATE API 11 | ``` 12 | -------------------------------------------------------------------------------- /utils/format-path/__tests__/format-path.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const formatPath = require('..'); 4 | 5 | describe('@dapp-cli/format-path', () => { 6 | it('needs tests'); 7 | }); 8 | -------------------------------------------------------------------------------- /utils/format-path/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | 5 | module.exports = function formatPath(p) { 6 | if (p) { 7 | const sep = path.sep; 8 | if (sep === '/') { 9 | return p; 10 | } else { 11 | return p.replace(/\\/g, '/'); 12 | } 13 | } 14 | return p; 15 | } 16 | -------------------------------------------------------------------------------- /utils/format-path/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/format-path", 3 | "version": "1.0.6", 4 | "description": "format path", 5 | "author": "Mark Tang ", 6 | "homepage": "https://github.com/MarkTangCd/dapp-cli#readme", 7 | "license": "ISC", 8 | "main": "lib/index.js", 9 | "directories": { 10 | "lib": "lib", 11 | "test": "__tests__" 12 | }, 13 | "files": [ 14 | "lib" 15 | ], 16 | "publishConfig": { 17 | "access": "public" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/MarkTangCd/dapp-cli.git" 22 | }, 23 | "scripts": { 24 | "test": "echo \"Error: run tests from root\" && exit 1" 25 | }, 26 | "bugs": { 27 | "url": "https://github.com/MarkTangCd/dapp-cli/issues" 28 | }, 29 | "gitHead": "822b3bfe67703d4342d440c2a78fa52f442e5aae" 30 | } 31 | -------------------------------------------------------------------------------- /utils/get-npm-info/README.md: -------------------------------------------------------------------------------- 1 | # `get-npm-info` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | const getNpmInfo = require('get-npm-info'); 9 | 10 | // TODO: DEMONSTRATE API 11 | ``` 12 | -------------------------------------------------------------------------------- /utils/get-npm-info/__tests__/get-npm-info.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getNpmInfo = require('..'); 4 | 5 | describe('get-npm-info', () => { 6 | it('needs tests'); 7 | }); 8 | -------------------------------------------------------------------------------- /utils/get-npm-info/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const axios = require('axios'); 4 | const urlJoin = require('url-join'); 5 | const semver = require('semver'); 6 | 7 | function getNpmInfo(npmName, registry) { 8 | if (!npmName) { 9 | return null; 10 | } 11 | const registryUrl = registry || getDefaultRegistry(); 12 | const npmInfoUrl = urlJoin(registryUrl, npmName); 13 | return axios.get(npmInfoUrl).then(response => { 14 | if (response.status === 200) { 15 | return response.data; 16 | } 17 | return null; 18 | }).catch(err => { 19 | return Promise.reject(err); 20 | }); 21 | } 22 | 23 | function getDefaultRegistry(isOriginal = false) { 24 | return isOriginal ? 'https://registry.npmjs.org' : 'https://registry.npm.taobao.org'; 25 | } 26 | 27 | async function getNpmVersions(npmName, registry) { 28 | const data = await getNpmInfo(npmName, registry); 29 | if (data) { 30 | return Object.keys(data.versions); 31 | } else { 32 | return []; 33 | } 34 | } 35 | 36 | function getSemverVersions(baseVersion, versions) { 37 | return versions 38 | .filter(version => semver.satisfies(version, `^${baseVersion}`)) 39 | .sort((a, b) => semver.gt(b, a)); 40 | } 41 | 42 | async function getNpmSemverVersion(baseVersion, npmName, registry) { 43 | const versions = await getNpmVersions(npmName, registry); 44 | const newVersions = getSemverVersions(baseVersion, versions); 45 | if (newVersions && newVersions.length > 0) { 46 | return newVersions[newVersions.length - 1]; 47 | } 48 | } 49 | 50 | async function getNpmLatestVersion(npmName, registry) { 51 | const versions = await getNpmVersions(npmName, registry); 52 | if (versions) { 53 | return versions.sort((a, b) => semver.gt(b, a))[versions.length - 1]; 54 | } 55 | return null; 56 | } 57 | 58 | module.exports = { 59 | getNpmInfo, 60 | getNpmVersions, 61 | getNpmSemverVersion, 62 | getDefaultRegistry, 63 | getNpmLatestVersion 64 | }; 65 | -------------------------------------------------------------------------------- /utils/get-npm-info/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "get-npm-info", 3 | "version": "1.0.6", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "axios": { 8 | "version": "0.26.1", 9 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", 10 | "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", 11 | "requires": { 12 | "follow-redirects": "^1.14.8" 13 | } 14 | }, 15 | "follow-redirects": { 16 | "version": "1.14.9", 17 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", 18 | "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==" 19 | }, 20 | "lru-cache": { 21 | "version": "6.0.0", 22 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", 23 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", 24 | "requires": { 25 | "yallist": "^4.0.0" 26 | } 27 | }, 28 | "semver": { 29 | "version": "7.3.7", 30 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", 31 | "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", 32 | "requires": { 33 | "lru-cache": "^6.0.0" 34 | } 35 | }, 36 | "url-join": { 37 | "version": "4.0.1", 38 | "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz", 39 | "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==" 40 | }, 41 | "yallist": { 42 | "version": "4.0.0", 43 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", 44 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /utils/get-npm-info/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/get-npm-info", 3 | "version": "1.0.6", 4 | "description": "get npm info", 5 | "author": "MarkTang ", 6 | "homepage": "https://github.com/MarkTangCd/dapp-cli#readme", 7 | "license": "ISC", 8 | "main": "lib/index.js", 9 | "directories": { 10 | "lib": "lib", 11 | "test": "__tests__" 12 | }, 13 | "files": [ 14 | "lib" 15 | ], 16 | "publishConfig": { 17 | "access": "public" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/MarkTangCd/dapp-cli.git" 22 | }, 23 | "scripts": { 24 | "test": "echo \"Error: run tests from root\" && exit 1" 25 | }, 26 | "bugs": { 27 | "url": "https://github.com/MarkTangCd/dapp-cli/issues" 28 | }, 29 | "dependencies": { 30 | "axios": "^0.26.1", 31 | "semver": "^7.3.7", 32 | "url-join": "4.0.1" 33 | }, 34 | "gitHead": "822b3bfe67703d4342d440c2a78fa52f442e5aae" 35 | } 36 | -------------------------------------------------------------------------------- /utils/log/README.md: -------------------------------------------------------------------------------- 1 | # `@dapp-cli/log` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | const log = require('@dapp-cli/log'); 9 | 10 | // TODO: DEMONSTRATE API 11 | ``` 12 | -------------------------------------------------------------------------------- /utils/log/__tests__/log.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const log = require('..'); 4 | 5 | describe('@dapp-cli/log', () => { 6 | it('needs tests'); 7 | }); 8 | -------------------------------------------------------------------------------- /utils/log/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const log = require('npmlog'); 4 | 5 | log.level = process.env.LOG_LEVEL ? process.env.LOG_LEVEL : 'info'; 6 | 7 | log.heading = 'dapp-cli'; 8 | log.addLevel('success', 2000, {fg: 'green', bold: true }); 9 | 10 | module.exports = log; 11 | -------------------------------------------------------------------------------- /utils/log/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/log", 3 | "version": "1.0.6", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "ansi-regex": { 8 | "version": "5.0.1", 9 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", 10 | "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" 11 | }, 12 | "aproba": { 13 | "version": "2.0.0", 14 | "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", 15 | "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==" 16 | }, 17 | "are-we-there-yet": { 18 | "version": "3.0.0", 19 | "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.0.tgz", 20 | "integrity": "sha512-0GWpv50YSOcLXaN6/FAKY3vfRbllXWV2xvfA/oKJF8pzFhWXPV+yjhJXDBbjscDYowv7Yw1A3uigpzn5iEGTyw==", 21 | "requires": { 22 | "delegates": "^1.0.0", 23 | "readable-stream": "^3.6.0" 24 | } 25 | }, 26 | "color-support": { 27 | "version": "1.1.3", 28 | "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", 29 | "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==" 30 | }, 31 | "console-control-strings": { 32 | "version": "1.1.0", 33 | "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", 34 | "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" 35 | }, 36 | "delegates": { 37 | "version": "1.0.0", 38 | "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", 39 | "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" 40 | }, 41 | "emoji-regex": { 42 | "version": "8.0.0", 43 | "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", 44 | "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" 45 | }, 46 | "gauge": { 47 | "version": "4.0.4", 48 | "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", 49 | "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", 50 | "requires": { 51 | "aproba": "^1.0.3 || ^2.0.0", 52 | "color-support": "^1.1.3", 53 | "console-control-strings": "^1.1.0", 54 | "has-unicode": "^2.0.1", 55 | "signal-exit": "^3.0.7", 56 | "string-width": "^4.2.3", 57 | "strip-ansi": "^6.0.1", 58 | "wide-align": "^1.1.5" 59 | } 60 | }, 61 | "has-unicode": { 62 | "version": "2.0.1", 63 | "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", 64 | "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" 65 | }, 66 | "inherits": { 67 | "version": "2.0.4", 68 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 69 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 70 | }, 71 | "is-fullwidth-code-point": { 72 | "version": "3.0.0", 73 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", 74 | "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" 75 | }, 76 | "npmlog": { 77 | "version": "6.0.2", 78 | "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", 79 | "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", 80 | "requires": { 81 | "are-we-there-yet": "^3.0.0", 82 | "console-control-strings": "^1.1.0", 83 | "gauge": "^4.0.3", 84 | "set-blocking": "^2.0.0" 85 | } 86 | }, 87 | "readable-stream": { 88 | "version": "3.6.0", 89 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", 90 | "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", 91 | "requires": { 92 | "inherits": "^2.0.3", 93 | "string_decoder": "^1.1.1", 94 | "util-deprecate": "^1.0.1" 95 | } 96 | }, 97 | "safe-buffer": { 98 | "version": "5.2.1", 99 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 100 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" 101 | }, 102 | "set-blocking": { 103 | "version": "2.0.0", 104 | "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", 105 | "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" 106 | }, 107 | "signal-exit": { 108 | "version": "3.0.7", 109 | "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", 110 | "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" 111 | }, 112 | "string-width": { 113 | "version": "4.2.3", 114 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", 115 | "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", 116 | "requires": { 117 | "emoji-regex": "^8.0.0", 118 | "is-fullwidth-code-point": "^3.0.0", 119 | "strip-ansi": "^6.0.1" 120 | } 121 | }, 122 | "string_decoder": { 123 | "version": "1.3.0", 124 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", 125 | "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", 126 | "requires": { 127 | "safe-buffer": "~5.2.0" 128 | } 129 | }, 130 | "strip-ansi": { 131 | "version": "6.0.1", 132 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", 133 | "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", 134 | "requires": { 135 | "ansi-regex": "^5.0.1" 136 | } 137 | }, 138 | "util-deprecate": { 139 | "version": "1.0.2", 140 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 141 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 142 | }, 143 | "wide-align": { 144 | "version": "1.1.5", 145 | "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", 146 | "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", 147 | "requires": { 148 | "string-width": "^1.0.2 || 2 || 3 || 4" 149 | } 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /utils/log/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/log", 3 | "version": "1.0.6", 4 | "description": "dapp-cli log", 5 | "keywords": [ 6 | "log" 7 | ], 8 | "author": "MarkTang ", 9 | "homepage": "https://github.com/MarkTangCd/dapp-cli#readme", 10 | "license": "ISC", 11 | "main": "lib/index.js", 12 | "directories": { 13 | "lib": "lib", 14 | "test": "__tests__" 15 | }, 16 | "files": [ 17 | "lib" 18 | ], 19 | "publishConfig": { 20 | "access": "public" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "git+https://github.com/MarkTangCd/dapp-cli.git" 25 | }, 26 | "scripts": { 27 | "test": "echo \"Error: run tests from root\" && exit 1" 28 | }, 29 | "bugs": { 30 | "url": "https://github.com/MarkTangCd/dapp-cli/issues" 31 | }, 32 | "dependencies": { 33 | "npmlog": "^6.0.2" 34 | }, 35 | "gitHead": "822b3bfe67703d4342d440c2a78fa52f442e5aae" 36 | } 37 | -------------------------------------------------------------------------------- /utils/utils/README.md: -------------------------------------------------------------------------------- 1 | # `@dapp-cli/utils` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | const utils = require('@dapp-cli/utils'); 9 | 10 | // TODO: DEMONSTRATE API 11 | ``` 12 | -------------------------------------------------------------------------------- /utils/utils/__tests__/utils.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const utils = require('..'); 4 | 5 | describe('@dapp-cli/utils', () => { 6 | it('needs tests'); 7 | }); 8 | -------------------------------------------------------------------------------- /utils/utils/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const cp = require('child_process'); 3 | 4 | function isObject(o) { 5 | return Object.prototype.toString.call(o) === '[object Object]'; 6 | } 7 | 8 | function spinnerStart(msg, spinnerString = '|/-\\') { 9 | const Spinner = require('cli-spinner').Spinner; 10 | const spinner = new Spinner(msg + ' %s'); 11 | spinner.setSpinnerString(spinnerString); 12 | spinner.start(); 13 | return spinner; 14 | } 15 | 16 | function sleep(timeout = 1000) { 17 | return new Promise(resolve => setTimeout(resolve, timeout)); 18 | } 19 | 20 | function exec(command, args, options) { 21 | const win32 = process.platform === 'win32'; 22 | 23 | const cmd = win32 ? 'cmd' : command; 24 | const cmdArgs = win32 ? ['/c'].concat(command, args) : args; 25 | 26 | return cp.spawn(cmd, cmdArgs, options || {}); 27 | } 28 | 29 | function execAsync(command, args, options) { 30 | return new Promise((resolve, reject) => { 31 | const p = exec(command, args, options); 32 | p.on('error', e => { 33 | reject(e); 34 | }); 35 | p.on('exit', c => { 36 | resolve(c); 37 | }); 38 | }); 39 | } 40 | 41 | module.exports = { 42 | isObject, 43 | spinnerStart, 44 | sleep, 45 | exec, 46 | execAsync 47 | }; 48 | -------------------------------------------------------------------------------- /utils/utils/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/utils", 3 | "version": "1.0.6", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "cli-spinner": { 8 | "version": "0.2.10", 9 | "resolved": "https://registry.npmjs.org/cli-spinner/-/cli-spinner-0.2.10.tgz", 10 | "integrity": "sha512-U0sSQ+JJvSLi1pAYuJykwiA8Dsr15uHEy85iCJ6A+0DjVxivr3d+N2Wjvodeg89uP5K6TswFkKBfAD7B3YSn/Q==" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /utils/utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@dapp-cli/utils", 3 | "version": "1.0.6", 4 | "description": "dapp-cli utils package", 5 | "author": "Mark Tang ", 6 | "homepage": "https://github.com/MarkTangCd/dapp-cli#readme", 7 | "license": "ISC", 8 | "main": "lib/index.js", 9 | "directories": { 10 | "lib": "lib", 11 | "test": "__tests__" 12 | }, 13 | "files": [ 14 | "lib" 15 | ], 16 | "publishConfig": { 17 | "access": "public" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/MarkTangCd/dapp-cli.git" 22 | }, 23 | "scripts": { 24 | "test": "echo \"Error: run tests from root\" && exit 1" 25 | }, 26 | "bugs": { 27 | "url": "https://github.com/MarkTangCd/dapp-cli/issues" 28 | }, 29 | "dependencies": { 30 | "cli-spinner": "^0.2.10" 31 | }, 32 | "gitHead": "822b3bfe67703d4342d440c2a78fa52f442e5aae" 33 | } 34 | --------------------------------------------------------------------------------