├── .codebeatignore ├── .codebeatsettings ├── .gitignore ├── .npmignore ├── tsconfig.json ├── .github └── workflows │ └── build.yml ├── test ├── mocks │ ├── index.ts │ ├── logger.ts │ ├── command-exists.ts │ ├── constants.ts │ └── redis.ts ├── lib │ ├── error.ts │ ├── path.ts │ ├── license.ts │ ├── validate.ts │ ├── travis.ts │ ├── names.ts │ ├── template.ts │ ├── node.ts │ ├── fs.ts │ ├── config.ts │ └── github.ts └── src │ ├── client.ts │ ├── config.ts │ ├── service.ts │ ├── config │ ├── get.ts │ ├── set.ts │ ├── init.ts │ └── check.ts │ ├── completions.ts │ ├── completions │ ├── on.ts │ └── off.ts │ ├── service │ └── create.ts │ └── client │ └── generate.ts ├── src ├── config │ ├── check.ts │ ├── set.ts │ ├── get.ts │ └── init.ts ├── client.ts ├── config.ts ├── service.ts ├── completions.ts ├── completions │ ├── off.ts │ └── on.ts ├── client │ └── generate.ts └── service │ └── update-version.ts ├── lib ├── index.ts ├── path.ts ├── constants.ts ├── validate.ts ├── error.ts ├── names.ts ├── autoupdate.ts ├── config.ts ├── fs.ts ├── license.ts ├── github.ts ├── travis.ts ├── template.ts └── node.ts ├── index.ts ├── bin ├── log.sh ├── updep.sh └── ctl.sh ├── package.json └── README.md /.codebeatignore: -------------------------------------------------------------------------------- 1 | benchmark/** 2 | -------------------------------------------------------------------------------- /.codebeatsettings: -------------------------------------------------------------------------------- 1 | { 2 | "TYPESCRIPT": { 3 | "TOTAL_LOC": [500, 1000, 1500, 2000], 4 | "TOO_MANY_FUNCTIONS": [30, 40, 50, 60] 5 | } 6 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .ssh/ 2 | dist/ 3 | tmp/ 4 | out-tsc/ 5 | build/ 6 | .nyc_output/ 7 | 8 | node_modules/ 9 | 10 | .idea/ 11 | .project 12 | .classpath 13 | .c9/ 14 | *.launch 15 | .settings/ 16 | *.sublime-workspace 17 | .vscode/* 18 | 19 | .sass-cache/ 20 | connect.lock/ 21 | coverage/ 22 | typings/ 23 | docs/ 24 | 25 | debug* 26 | *.txt 27 | *.js 28 | *.d.ts 29 | *.js.map 30 | *.pid 31 | *.log 32 | .DS_Store 33 | Thumbs.db 34 | *.swp 35 | .env 36 | 37 | stats.json 38 | benchmark-result/* 39 | 40 | *.tgz 41 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | .travis.yml 3 | .dockerignore 4 | .codebeatignore 5 | .codebeatsettings 6 | 7 | .ssh/ 8 | dist/ 9 | tmp/ 10 | out-tsc/ 11 | build/ 12 | .nyc_output/ 13 | 14 | node_modules/ 15 | 16 | .idea/ 17 | .project 18 | .classpath 19 | .c9/ 20 | *.launch 21 | .settings/ 22 | *.sublime-workspace 23 | .vscode/* 24 | .env 25 | 26 | .sass-cache/ 27 | connect.lock/ 28 | coverage/ 29 | typings/ 30 | docs/ 31 | 32 | debug* 33 | *.pid 34 | *.log 35 | .DS_Store 36 | Thumbs.db 37 | 38 | test/ 39 | 40 | *.js.map 41 | *.ts 42 | !*.d.ts 43 | tsconfig.json 44 | 45 | *.tgz 46 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "noImplicitAny": true, 6 | "strictNullChecks": true, 7 | "removeComments": false, 8 | "noUnusedLocals": false, 9 | "noUnusedParameters": false, 10 | "moduleResolution": "node", 11 | "sourceMap": true, 12 | "inlineSources": true, 13 | "experimentalDecorators": true, 14 | "emitDecoratorMetadata": true, 15 | "target": "es2017", 16 | "lib": [ 17 | "dom", 18 | "es2017" 19 | ], 20 | "allowSyntheticDefaultImports": true 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Node.js CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | strategy: 12 | matrix: 13 | node-version: [lts/*] 14 | 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v4 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | 24 | - name: Install dependencies 25 | run: npm install 26 | 27 | - name: Run tests 28 | run: npm test 29 | -------------------------------------------------------------------------------- /test/mocks/index.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Test Mocks Exports 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | export * from './constants'; 25 | export * from './logger'; 26 | export * from './redis'; 27 | export * from './command-exists'; 28 | -------------------------------------------------------------------------------- /test/mocks/logger.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Test Mocks: logger 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | // noinspection JSUnusedGlobalSymbols 25 | export const logger: any = { 26 | log() {}, 27 | info() {}, 28 | warn() {}, 29 | error() {} 30 | }; 31 | -------------------------------------------------------------------------------- /test/lib/error.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: error 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../mocks'; 25 | import { expect } from 'chai'; 26 | import { printError } from '../../lib'; 27 | 28 | describe('error', () => { 29 | describe('printError()', () => { 30 | it('should be a function', () => { 31 | expect(typeof printError).equals('function'); 32 | }); 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /src/config/check.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI command: config check 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import { configEmpty } from '../../lib'; 25 | 26 | // noinspection JSUnusedGlobalSymbols 27 | export const { command, describe, handler } = { 28 | command: 'check', 29 | describe: 'Exits with 0 if config initialized, with 1 otherwise', 30 | 31 | handler() { 32 | process.exit(configEmpty() ? 1 : 0); 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /src/client.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI command: client 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import { Argv } from 'yargs'; 25 | 26 | // noinspection JSUnusedGlobalSymbols 27 | export const { command, describe, builder } = { 28 | command: 'client', 29 | describe: 'Manage IMQ client', 30 | 31 | builder(yargs: Argv) { 32 | return yargs 33 | .commandDir('client') 34 | .demandCommand() 35 | .help(); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /test/mocks/command-exists.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Test Mocks: command-exists 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import * as mock from 'mock-require'; 25 | 26 | (global).checkGitResult = true; 27 | 28 | function _commandExists() { 29 | return (global).checkGitResult; 30 | } 31 | 32 | (_commandExists as any).sync = _commandExists; 33 | 34 | mock('command-exists', _commandExists); 35 | 36 | export const commandExists = require('command-exists'); 37 | -------------------------------------------------------------------------------- /src/config.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI command: config 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import { Argv } from 'yargs'; 25 | 26 | // noinspection JSUnusedGlobalSymbols 27 | export const { command, describe, builder } = { 28 | command: 'config', 29 | describe: 'Manage IMQ CLI settings', 30 | 31 | builder(yargs: Argv) { 32 | return yargs 33 | .commandDir('config') 34 | .demandCommand() 35 | .help(); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /src/service.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI command: service 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import { Argv } from 'yargs'; 25 | 26 | // noinspection JSUnusedGlobalSymbols 27 | export const { command, describe, builder } = { 28 | command: 'service', 29 | describe: 'Manage IMQ service', 30 | 31 | builder(yargs: Argv) { 32 | return yargs 33 | .commandDir('service') 34 | .demandCommand() 35 | .help(); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /lib/index.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI library: exports 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | export * from './constants'; 25 | export * from './validate'; 26 | export * from './names'; 27 | export * from './error'; 28 | export * from './config'; 29 | export * from './license'; 30 | export * from './fs'; 31 | export * from './path'; 32 | export * from './travis'; 33 | export * from './template'; 34 | export * from './github'; 35 | export * from './node'; 36 | export * from './autoupdate'; 37 | -------------------------------------------------------------------------------- /src/completions.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI command: completions 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import { Argv } from "yargs"; 25 | 26 | // noinspection JSUnusedGlobalSymbols 27 | export const { command, describe, builder } = { 28 | command: 'completions', 29 | describe: 'Generates completions script for your shell', 30 | 31 | builder(yargs: Argv) { 32 | return yargs 33 | .commandDir('completions') 34 | .demandCommand() 35 | .help(); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /test/src/client.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: client 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../mocks'; 25 | import { expect } from 'chai'; 26 | import * as client from '../../src/client'; 27 | 28 | describe('client', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof client.command).equals('string'); 31 | expect(client.command).contains('client'); 32 | expect(typeof client.describe).equals('string'); 33 | expect(client.describe).not.to.be.empty; 34 | expect(typeof client.builder).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /test/src/config.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: config 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../mocks'; 25 | import { expect } from 'chai'; 26 | import * as client from '../../src/config'; 27 | 28 | describe('config', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof client.command).equals('string'); 31 | expect(client.command).contains('config'); 32 | expect(typeof client.describe).equals('string'); 33 | expect(client.describe).not.to.be.empty; 34 | expect(typeof client.builder).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /test/src/service.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: service 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../mocks'; 25 | import { expect } from 'chai'; 26 | import * as client from '../../src/service'; 27 | 28 | describe('service', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof client.command).equals('string'); 31 | expect(client.command).contains('service'); 32 | expect(typeof client.describe).equals('string'); 33 | expect(client.describe).not.to.be.empty; 34 | expect(typeof client.builder).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /lib/path.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI library: path 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import * as p from 'path'; 25 | import { OS_HOME } from './constants'; 26 | 27 | /** 28 | * Resolves given path to an absolute canonical path 29 | * 30 | * @param {...string[]} args 31 | */ 32 | export function resolve(...args: string[]) { 33 | const paths: string[] = []; 34 | 35 | for (let path of args) { 36 | if (path.charAt(0) === '~') { 37 | path = OS_HOME + path.substr(1); 38 | } 39 | 40 | paths.push(path); 41 | } 42 | 43 | return p.normalize(p.resolve.apply(p, paths)); 44 | } 45 | -------------------------------------------------------------------------------- /test/src/config/get.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: config get 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../../mocks'; 25 | import { expect } from 'chai'; 26 | import * as client from '../../../src/config/get'; 27 | 28 | describe('config get', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof client.command).equals('string'); 31 | expect(client.command).contains('get'); 32 | expect(typeof client.describe).equals('string'); 33 | expect(client.describe).not.to.be.empty; 34 | expect(typeof client.handler).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /test/src/config/set.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: config set 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../../mocks'; 25 | import { expect } from 'chai'; 26 | import * as client from '../../../src/config/set'; 27 | 28 | describe('config set', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof client.command).equals('string'); 31 | expect(client.command).contains('set'); 32 | expect(typeof client.describe).equals('string'); 33 | expect(client.describe).not.to.be.empty; 34 | expect(typeof client.handler).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /test/src/completions.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: completions 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../mocks'; 25 | import { expect } from 'chai'; 26 | import * as client from '../../src/completions'; 27 | 28 | describe('completions', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof client.command).equals('string'); 31 | expect(client.command).contains('completions'); 32 | expect(typeof client.describe).equals('string'); 33 | expect(client.describe).not.to.be.empty; 34 | expect(typeof client.builder).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /test/src/config/init.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: config init 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../../mocks'; 25 | import { expect } from 'chai'; 26 | import * as config from '../../../src/config/init'; 27 | 28 | describe('config init', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof config.command).equals('string'); 31 | expect(config.command).contains('init'); 32 | expect(typeof config.describe).equals('string'); 33 | expect(config.describe).not.to.be.empty; 34 | expect(typeof config.handler).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /test/src/config/check.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: config check 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../../mocks'; 25 | import { expect } from 'chai'; 26 | import * as config from '../../../src/config/check'; 27 | 28 | describe('config check', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof config.command).equals('string'); 31 | expect(config.command).contains('check'); 32 | expect(typeof config.describe).equals('string'); 33 | expect(config.describe).not.to.be.empty; 34 | expect(typeof config.handler).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /test/src/completions/on.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: completions on 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../../mocks'; 25 | import { expect } from 'chai'; 26 | import * as client from '../../../src/completions/on'; 27 | 28 | describe('completions on', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof client.command).equals('string'); 31 | expect(client.command).contains('on'); 32 | expect(typeof client.describe).equals('string'); 33 | expect(client.describe).not.to.be.empty; 34 | expect(typeof client.handler).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /test/src/service/create.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: service create 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../../mocks'; 25 | import { expect } from 'chai'; 26 | import * as client from '../../../src/service/create'; 27 | 28 | describe('service create', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof client.command).equals('string'); 31 | expect(client.command).contains('create'); 32 | expect(typeof client.describe).equals('string'); 33 | expect(client.describe).not.to.be.empty; 34 | expect(typeof client.handler).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /test/src/completions/off.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: completions off 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../../mocks'; 25 | import { expect } from 'chai'; 26 | import * as client from '../../../src/completions/off'; 27 | 28 | describe('completions off', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof client.command).equals('string'); 31 | expect(client.command).contains('off'); 32 | expect(typeof client.describe).equals('string'); 33 | expect(client.describe).not.to.be.empty; 34 | expect(typeof client.handler).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /test/mocks/constants.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Test Mocks: constants 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import * as mock from 'mock-require'; 25 | 26 | const constants = { 27 | OS_HOME: '/tmp', 28 | IMQ_HOME: '/tmp/.imq', 29 | CONFIG_FILENAME: 'config.json', 30 | CONFIG_PATH: '/tmp/.imq/config.json', 31 | IS_ZSH: Object.keys(process.env).some(key => /^ZSH/.test(key)), 32 | TPL_HOME: '/tmp/.imq/templates', 33 | TPL_REPO: 'git@github.com:imqueue/templates.git', 34 | CUSTOM_TPL_HOME: '/tmp/.imq/custom-templates', 35 | }; 36 | 37 | mock('../../lib/constants', constants); 38 | 39 | export * from '../../lib/constants'; 40 | -------------------------------------------------------------------------------- /test/src/client/generate.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: client generate 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../../mocks'; 25 | import { expect } from 'chai'; 26 | import * as client from '../../../src/client/generate'; 27 | 28 | describe('client generate', () => { 29 | it('should be a valid command definition', () => { 30 | expect(typeof client.command).equals('string'); 31 | expect(client.command).contains('generate'); 32 | expect(typeof client.describe).equals('string'); 33 | expect(client.describe).not.to.be.empty; 34 | expect(typeof client.handler).equals('function'); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /*! 3 | * I Message Queue Command Line Interface 4 | * 5 | * I'm Queue Software Project 6 | * Copyright (C) 2025 imqueue.com 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | * If you want to use this code in a closed source (commercial) project, you can 22 | * purchase a proprietary commercial license. Please contact us at 23 | * to get commercial licensing options. 24 | */ 25 | import yargs from 'yargs'; 26 | import { hideBin } from 'yargs/helpers'; 27 | import { VERSION, checkForUpdate } from './lib'; 28 | 29 | (async () => { 30 | const y = yargs(hideBin(process.argv)); 31 | 32 | await checkForUpdate(); 33 | 34 | await y.usage('IMQ Command Line Interface' + 35 | `\nVersion: ${VERSION}` + 36 | '\n\nUsage: $0 ') 37 | .version(VERSION) 38 | .commandDir('src') 39 | .demandCommand() 40 | .wrap(y.terminalWidth()) 41 | .help() 42 | .argv 43 | ; 44 | })(); 45 | -------------------------------------------------------------------------------- /test/lib/path.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: path 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../mocks'; 25 | import { expect } from 'chai'; 26 | import * as p from 'path'; 27 | import { resolve, OS_HOME } from '../../lib'; 28 | 29 | describe('path', () => { 30 | describe('resolve()', () => { 31 | it('should be a function', () => { 32 | expect(typeof resolve).equals('function'); 33 | }); 34 | 35 | it('should properly resolve home directory', () => { 36 | expect(resolve('~')).equals(OS_HOME); 37 | }); 38 | 39 | it('should normalize given path', () => { 40 | expect(resolve(`${OS_HOME}/..`)).equals(p.dirname(OS_HOME)); 41 | }); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /lib/constants.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI library: constants 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import * as os from 'os'; 25 | import { resolve } from './path'; 26 | 27 | export const OS_HOME: string = os.homedir() || String(process.env['HOME']); 28 | export const IMQ_HOME = '~/.imq'; 29 | export const TPL_REPO = 'git@github.com:imqueue/templates.git'; 30 | export const TPL_HOME = resolve(IMQ_HOME, 'templates'); 31 | export const CUSTOM_TPL_HOME = resolve(IMQ_HOME, 'custom-templates'); 32 | export const CONFIG_FILENAME = 'config.json'; 33 | export const CONFIG_PATH = resolve(IMQ_HOME, CONFIG_FILENAME); 34 | export const IS_ZSH = Object.keys(process.env).some(key => /^ZSH/.test(key)); 35 | export const VERSION = require(`${__dirname}/../package.json`).version; 36 | -------------------------------------------------------------------------------- /lib/validate.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI library: validate 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | const RX_EMAIL = /^[-a-z0-9.]+@[-a-z0-9.]+$/i; 25 | const RX_NS = /^[-_a-z-0-9]+$/i; 26 | const RX_TOKEN = /^.+$/; 27 | 28 | /** 29 | * Checks if a given string email-like 30 | * 31 | * @param {string} email 32 | * @return {boolean} 33 | */ 34 | export function isEmail(email: string) { 35 | return RX_EMAIL.test(email); 36 | } 37 | 38 | /** 39 | * Checks if a given string satisfying namespace rules 40 | *s 41 | * @param {string} ns 42 | * @return {boolean} 43 | */ 44 | export function isNamespace(ns: string) { 45 | return RX_NS.test(ns); 46 | } 47 | 48 | /** 49 | * Checks if a given string a valid GitHub auth token 50 | * 51 | * @param {string} token 52 | * @return {boolean} 53 | */ 54 | export function isGuthubToken(token: string) { 55 | return RX_TOKEN.test(token); 56 | } 57 | -------------------------------------------------------------------------------- /lib/error.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI library: error 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import chalk from 'chalk'; 25 | 26 | // that is just a printing function, no need to do specific tests 27 | // istanbul ignore next 28 | /** 29 | * Prints error message to standard error output 30 | * 31 | * @param {Error} err - error to display message from 32 | * @param {boolean} [withStackTrace] - if true will printError error stack 33 | */ 34 | export function printError(err: Error, withStackTrace: boolean = false) { 35 | let message: string = err.message; 36 | 37 | try { 38 | let obj = JSON.parse(message); 39 | 40 | if (obj.message && obj.errors) { 41 | message = `${obj.message}: ${ 42 | obj.errors.map((err: any) => err.message).join('\n') 43 | }`; 44 | } 45 | } catch (err) { /* ignore */ } 46 | 47 | process.stderr.write(chalk.bold.red(message) + '\n'); 48 | 49 | if (withStackTrace && err.stack) { 50 | process.stderr.write(chalk.cyan(err.stack) + '\n'); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /test/lib/license.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI Unit Tests: license 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import '../mocks'; 25 | import { expect } from "chai"; 26 | import { findLicense } from '../../lib'; 27 | 28 | describe('license', function() { 29 | describe('findLicense()', () => { 30 | it('should be a function', () => { 31 | expect(typeof findLicense).equals('function'); 32 | }); 33 | 34 | it('should return license object if proper name given', () => { 35 | expect(findLicense('mit').spdx_id).equals('MIT'); 36 | expect(findLicense('Mit').spdx_id).equals('MIT'); 37 | expect(findLicense('mIt').spdx_id).equals('MIT'); 38 | expect(findLicense('MIT').spdx_id).equals('MIT'); 39 | expect(findLicense('mi').spdx_id).equals('MIT'); 40 | expect(findLicense('mit license').spdx_id).equals('MIT'); 41 | }); 42 | 43 | it('should return null if nothing found', () => { 44 | expect(findLicense('dsjgiuewhd')).to.be.null; 45 | }); 46 | }); 47 | }); 48 | -------------------------------------------------------------------------------- /src/config/set.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * IMQ-CLI command: config set 3 | * 4 | * I'm Queue Software Project 5 | * Copyright (C) 2025 imqueue.com 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | * 20 | * If you want to use this code in a closed source (commercial) project, you can 21 | * purchase a proprietary commercial license. Please contact us at 22 | * to get commercial licensing options. 23 | */ 24 | import { Arguments } from 'yargs'; 25 | import chalk from 'chalk'; 26 | import { 27 | printError, 28 | loadConfig, 29 | saveConfig, 30 | prepareConfigValue 31 | } from '../../lib'; 32 | 33 | // noinspection JSUnusedGlobalSymbols 34 | export const { command, describe, handler } = { 35 | command: 'set