Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

why-gitlab

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

why-gitlab - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

6

locales/zh-hans.json
{
"Which features do you care about?": "你关心哪些问题?",
"Which format do you want?": "你想输出哪种格式?",
"Which language do you want?": "你需要哪种语言?",
"free": "免费版",

@@ -8,2 +9,3 @@ "premium": "专业版",

"Suggestion: ": "推荐:",
"Generating report file...": "正在生成报告……",
"Report generated successfully, please open ": "报告已生成,请打开文件 ",

@@ -13,3 +15,7 @@ ",": "、",

"Output format": "输出格式",
"Language": "语言",
"Simplified Chinese": "简体中文",
"English": "英文",
"please select at least one feature": "请至少选择一个功能",
"please follow these steps to convert Markdown to %s:": "请按照下列步骤把 Markdown 转化成 %s:"
}

3

package.json
{
"name": "why-gitlab",
"description": "Why GitLab? DevSecOps",
"version": "1.2.0",
"version": "1.3.0",
"author": "sink @sinkcup",

@@ -26,2 +26,3 @@ "main": "src/main.js",

"dependencies": {
"command-exists": "^1.2.9",
"inquirer": "^8.2.1",

@@ -28,0 +29,0 @@ "os-locale": "^6.0.2",

@@ -7,5 +7,7 @@ /* eslint-disable no-console */

import { osLocale } from 'os-locale';
import commandExists from 'command-exists';
import * as childProcess from 'child_process';
import WhyGitlab from './main';
async function getLanguage() {
async function getOsLanguage() {
const locale = await osLocale();

@@ -15,6 +17,6 @@ return locale.substring(0, 2) === 'zh' ? 'zh-hans' : 'en';

const language = await getLanguage();
const osLanguage = await getOsLanguage();
const { __ } = y18n({
locale: language,
locale: osLanguage,
updateFiles: false,

@@ -24,11 +26,11 @@ });

function getConfig(allFeatures) {
const inquirerChoices = [];
const yargsChoices = [];
const featuresInquirerChoices = [];
const featuresYargsChoices = [];
// eslint-disable-next-line no-restricted-syntax
for (const { topic, features } of allFeatures) {
inquirerChoices.push(new inquirer.Separator(`= ${topic.name} =`));
featuresInquirerChoices.push(new inquirer.Separator(`= ${topic.name} =`));
// eslint-disable-next-line no-restricted-syntax
for (const feature of features) {
inquirerChoices.push({ name: feature.name, value: `${topic.path}/${feature.path}` });
yargsChoices.push(`${topic.path}/${feature.path}`);
featuresInquirerChoices.push({ name: feature.name, value: `${topic.path}/${feature.path}` });
featuresYargsChoices.push(`${topic.path}/${feature.path}`);
}

@@ -41,7 +43,7 @@ }

type: 'checkbox',
inquirerChoices,
inquirerChoices: featuresInquirerChoices,
// yargs
demandOption: true,
describe: __('Features'),
yargsChoices,
yargsChoices: featuresYargsChoices,
},

@@ -57,4 +59,19 @@ format: {

choices: ['Markdown', 'PDF', 'Word'],
default: 'markdown',
default: 'Markdown',
},
language: {
// inquirer
message: __('Which language do you want?'),
type: 'list',
inquirerChoices: [
{ name: __('Simplified Chinese'), value: 'zh-hans' },
{ name: __('English'), value: 'en' },
],
// yargs
demandOption: true,
describe: __('Language'),
yargsChoices: ['zh-hans', 'en'],
// shared
default: osLanguage,
},
};

@@ -91,6 +108,17 @@ }

function checkGeneratorExists(format) {
if (format === 'Markdown') {
return true;
}
const converterMap = {
PDF: 'md-to-pdf',
Word: 'pandoc',
};
return commandExists.sync(converterMap[format]);
}
async function cli() {
const hideBinArgv = hideBin(process.argv);
const whyGitlab = new WhyGitlab();
whyGitlab.language = language;
whyGitlab.language = osLanguage;
const config = getConfig(whyGitlab.getAllFeatures());

@@ -113,6 +141,11 @@

const argv = yargs(hideBinArgv)
.usage('Usage: npx $0')
.usage('Usage: $0')
.options(getOptions(config))
.parseSync();
if (argv.features[0] === undefined) {
console.error(__('please select at least one feature'));
process.exit(1);
}
whyGitlab.language = argv.language;
whyGitlab.distributeIntroduction();

@@ -122,6 +155,22 @@ whyGitlab.distributeFeatures(argv.features);

console.info(`${__('Suggestion: ')}${__(whyGitlab.plan)}`);
console.info(`${__('Report generated successfully, please open ')}dist/why-gitlab.md`);
const { format } = argv;
if (format === 'Markdown') {
const extMap = {
Markdown: '.md',
PDF: '.pdf',
Word: '.docx',
};
if (checkGeneratorExists(format)) {
console.info(__('Generating report file...'));
switch (format) {
case 'PDF':
childProcess.spawnSync('md-to-pdf', ['dist/why-gitlab.md']);
break;
case 'Word':
childProcess.spawnSync('pandoc', ['why-gitlab.md', '-o', 'why-gitlab.docx'], { cwd: whyGitlab.distPath });
break;
default:
break;
}
console.info(`${__('Report generated successfully, please open ')}dist/why-gitlab${extMap[format]}`);
return;

@@ -128,0 +177,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc