New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

create-react-native-library

Package Overview
Dependencies
Maintainers
0
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-react-native-library - npm Package Compare versions

Comparing version 0.45.3 to 0.45.4

lib/utils/prompt.js

28

lib/index.js

@@ -8,3 +8,3 @@ "use strict";

var _ora = _interopRequireDefault(require("ora"));
var _prompts = _interopRequireDefault(require("./utils/prompts"));
var _prompt = require("./utils/prompt");
var _generateExampleApp = _interopRequireDefault(require("./exampleApp/generateExampleApp"));

@@ -14,3 +14,3 @@ var _addCodegenBuildScript = require("./exampleApp/addCodegenBuildScript");

var _assert = require("./utils/assert");
var _promiseWithFallback = require("./utils/promiseWithFallback");
var _resolveNpmPackageVersion = require("./utils/resolveNpmPackageVersion");
var _template = require("./template");

@@ -37,3 +37,3 @@ var _input = require("./input");

// Prefetch bob version in background while asking questions
const resolveBobVersion = (0, _promiseWithFallback.resolveBobVersionWithFallback)(FALLBACK_BOB_VERSION);
const bobVersionPromise = (0, _resolveNpmPackageVersion.resolveNpmPackageVersion)('react-native-builder-bob', FALLBACK_BOB_VERSION);
const local = await promptLocalLibrary(argv);

@@ -43,20 +43,14 @@ const folder = await promptPath(argv, local);

const basename = _path.default.basename(folder);
const {
questions,
singleChoiceAnswers
} = await (0, _input.createQuestions)({
const questions = await (0, _input.createQuestions)({
basename,
local,
argv
local
});
(0, _assert.assertUserInput)(questions, argv);
const promptAnswers = await (0, _prompts.default)(questions);
const promptAnswers = await (0, _prompt.prompt)(questions, argv);
const answers = {
...argv,
local,
...singleChoiceAnswers,
...promptAnswers
...promptAnswers,
local
};
(0, _assert.assertUserInput)(questions, answers);
const bobVersion = await resolveBobVersion();
const bobVersion = await bobVersionPromise;
const config = (0, _template.generateTemplateConfiguration)({

@@ -117,3 +111,3 @@ bobVersion,

// If we're under a project with package.json, ask the user if they want to create a local library
const answers = await (0, _prompts.default)({
const answers = await (0, _prompt.prompt)({
type: 'confirm',

@@ -134,3 +128,3 @@ name: 'local',

} else {
const answers = await (0, _prompts.default)({
const answers = await (0, _prompt.prompt)({
type: 'text',

@@ -137,0 +131,0 @@ name: 'folder',

@@ -9,5 +9,5 @@ "use strict";

exports.createQuestions = createQuestions;
var _githubUsername = _interopRequireDefault(require("github-username"));
var _validateNpmPackageName = _interopRequireDefault(require("validate-npm-package-name"));
var _package = require("../package.json");
var _validateNpmPackageName = _interopRequireDefault(require("validate-npm-package-name"));
var _githubUsername = _interopRequireDefault(require("github-username"));
var _spawn = require("./utils/spawn");

@@ -126,4 +126,3 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }

basename,
local,
argv
local
}) {

@@ -137,3 +136,3 @@ let name, email;

}
const initialQuestions = [{
const questions = [{
type: 'text',

@@ -206,3 +205,3 @@ name: 'slug',

if (!local) {
initialQuestions.push({
questions.push({
type: 'select',

@@ -221,43 +220,3 @@ name: 'example',

}
const singleChoiceAnswers = {};
const finalQuestions = [];
for (const question of initialQuestions) {
// Skip questions which are passed as parameter and pass validation
const argValue = argv[question.name];
if (argValue && question.validate?.(argValue) !== false) {
continue;
}
// Don't prompt questions with a single choice
if (Array.isArray(question.choices) && question.choices.length === 1) {
const onlyChoice = question.choices[0];
singleChoiceAnswers[question.name] = onlyChoice.value;
continue;
}
const {
type,
choices
} = question;
// Don't prompt dynamic questions with a single choice
if (type === 'select' && typeof choices === 'function') {
question.type = (prev, values, prompt) => {
const dynamicChoices = choices(prev, {
...argv,
...values
}, prompt);
if (dynamicChoices && dynamicChoices.length === 1) {
const onlyChoice = dynamicChoices[0];
singleChoiceAnswers[question.name] = onlyChoice.value;
return null;
}
return type;
};
}
finalQuestions.push(question);
}
return {
questions: finalQuestions,
singleChoiceAnswers
};
return questions;
}

@@ -264,0 +223,0 @@ function createMetadata(answers) {

@@ -37,18 +37,25 @@ "use strict";

}
let valid = question.validate ? question.validate(String(value)) : true;
let validation;
// We also need to guard against invalid choices
// If we don't already have a validation message to provide a better error
if (typeof valid !== 'string' && 'choices' in question) {
const choices = typeof question.choices === 'function' ? question.choices(undefined,
// @ts-expect-error: it complains about optional values, but it should be fine
answers, question) : question.choices;
if (choices && !choices.some(choice => choice.value === value)) {
valid = `Supported values are - ${choices.map(c => _kleur.default.green(c.value))}`;
if ('choices' in question) {
const choices = typeof question.choices === 'function' ? question.choices(undefined, answers) : question.choices;
if (choices && choices.every(choice => choice.value !== value)) {
if (choices.length > 1) {
validation = `Must be one of ${choices.map(choice => _kleur.default.green(choice.value)).join(', ')}`;
} else if (choices[0]) {
validation = `Must be '${_kleur.default.green(choices[0].value)}'`;
} else {
validation = false;
}
}
}
if (valid !== true) {
if (validation == null && question.validate) {
validation = question.validate(String(value));
}
if (validation != null && validation !== true) {
let message = `Invalid value ${_kleur.default.red(String(value))} passed for ${_kleur.default.blue(key)}`;
if (typeof valid === 'string') {
message += `: ${valid}`;
if (typeof validation === 'string') {
message += `: ${validation}`;
}

@@ -55,0 +62,0 @@ console.log(message);

{
"name": "create-react-native-library",
"version": "0.45.3",
"version": "0.45.4",
"description": "CLI to scaffold React Native libraries",

@@ -68,3 +68,3 @@ "keywords": [

},
"gitHead": "9c5638a224d558071ae01f010da8b7a6860f00ee"
"gitHead": "999c72ad42387d3a29284b39646faf28a80d80c5"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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