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

react-creates

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-creates - npm Package Compare versions

Comparing version 2.0.5 to 2.0.6

1

dist/src/cli/commands/create-component.js

@@ -20,2 +20,3 @@ "use strict";

.option('-t --type <component>', 'Component type (function vs class)', 'function')
.option('-cm --css-modules', 'Enable CSS Modules')
.option('-pt --prop-types', 'Should add Prop-types if inside javascript project')

@@ -22,0 +23,0 @@ .option('--skipTest|--skip-test', 'Will not create test file')

@@ -13,2 +13,3 @@ import type { IFileSystem } from '@file-services/types';

skipTest?: boolean;
cssModules?: boolean;
style?: 'css' | 'scss' | 'none';

@@ -15,0 +16,0 @@ }

24

dist/src/create-component.js

@@ -16,3 +16,4 @@ "use strict";

const resolvedOptions = await resolveCreateComponentOptions(options, resolveProperty);
const { language, type, name, directory: target } = resolvedOptions;
const { language, type, name, directory: target, cssModules } = resolvedOptions;
validateOptions(resolvedOptions);
const resolvedSource = fileSystem.join(templateDirectory, language, type);

@@ -25,3 +26,7 @@ const resolvedTarget = fileSystem.join(target, name);

...resolvedOptions,
style: resolvedOptions.style === 'none' ? undefined : resolvedOptions.style,
style: resolvedOptions.style === 'none'
? undefined
: cssModules
? `module.${resolvedOptions.style}`
: resolvedOptions.style,
};

@@ -54,7 +59,7 @@ try {

const content = await fileSystem.promises.readFile(filePath, 'utf8');
const resolvedContent = (0, mustache_1.render)(content, modifiedOptions);
const resolvedContent = (0, mustache_1.render)(content, modifiedOptions).trimStart();
await fileSystem.promises.writeFile(filePath, resolvedContent, 'utf8');
}
logger.log(`Component "${name}" created.\n\n${resolvedTarget}\n`);
onFinished === null || onFinished === void 0 ? void 0 : onFinished(resolvedOptions);
void (onFinished === null || onFinished === void 0 ? void 0 : onFinished(resolvedOptions));
}

@@ -69,3 +74,3 @@ catch (error) {

async function resolveCreateComponentOptions(options, resolveProperty = () => void 0) {
var _a, _b, _c, _d, _e, _f, _g, _h;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
return {

@@ -79,5 +84,14 @@ name: options.name,

style: (_h = (_g = options.style) !== null && _g !== void 0 ? _g : (await (resolveProperty === null || resolveProperty === void 0 ? void 0 : resolveProperty('style')))) !== null && _h !== void 0 ? _h : 'none',
cssModules: (_k = (_j = options.cssModules) !== null && _j !== void 0 ? _j : (await (resolveProperty === null || resolveProperty === void 0 ? void 0 : resolveProperty('cssModules')))) !== null && _k !== void 0 ? _k : false,
};
}
exports.resolveCreateComponentOptions = resolveCreateComponentOptions;
function validateOptions(options) {
/**
* Validate CSS Modules
*/
if (options.cssModules && ['css', 'scss'].includes(options.style) === false) {
throw new Error(`Cannot use CSS Modules with style "${options.style}", only "css" and "scss" are supported.`);
}
}
//# sourceMappingURL=create-component.js.map
{
"name": "react-creates",
"version": "2.0.5",
"version": "2.0.6",
"description": "React creates for you useful and common tools that adapt themselves to your project for faster and easier development",

@@ -41,3 +41,3 @@ "files": [

"@types/prompts": "^2.0.14",
"commander": "^9.1.0",
"commander": "^9.2.0",
"find-cache-dir": "^3.3.2",

@@ -44,0 +44,0 @@ "mustache": "^4.2.0",

@@ -22,2 +22,3 @@ import { nodeFs } from '@file-services/node';

.option('-t --type <component>', 'Component type (function vs class)', 'function')
.option('-cm --css-modules', 'Enable CSS Modules')
.option('-pt --prop-types', 'Should add Prop-types if inside javascript project')

@@ -57,3 +58,3 @@ .option('--skipTest|--skip-test', 'Will not create test file')

const values = [...createComponentProperties[key as keyof typeof createComponentProperties]];
const values = [...createComponentProperties[key as unknown as keyof typeof createComponentProperties]];
const response = await prompts({

@@ -60,0 +61,0 @@ type: 'select',

@@ -25,2 +25,3 @@ import { nodeFs } from '@file-services/node';

skipTest?: boolean;
cssModules?: boolean;
style?: 'css' | 'scss' | 'none';

@@ -57,4 +58,6 @@ }

const resolvedOptions = await resolveCreateComponentOptions(options, resolveProperty);
const { language, type, name, directory: target } = resolvedOptions;
const { language, type, name, directory: target, cssModules } = resolvedOptions;
validateOptions(resolvedOptions);
const resolvedSource = fileSystem.join(templateDirectory, language, type);

@@ -70,3 +73,8 @@ const resolvedTarget = fileSystem.join(target, name);

...resolvedOptions,
style: resolvedOptions.style === 'none' ? undefined : resolvedOptions.style,
style:
resolvedOptions.style === 'none'
? undefined
: cssModules
? `module.${resolvedOptions.style}`
: resolvedOptions.style,
};

@@ -103,3 +111,3 @@

const content = await fileSystem.promises.readFile(filePath, 'utf8');
const resolvedContent = render(content, modifiedOptions);
const resolvedContent = render(content, modifiedOptions).trimStart();
await fileSystem.promises.writeFile(filePath, resolvedContent, 'utf8');

@@ -109,3 +117,3 @@ }

onFinished?.(resolvedOptions);
void onFinished?.(resolvedOptions);
} catch (error) {

@@ -131,3 +139,13 @@ logger.error(`Failed to create "${name}" component.\n\n${resolvedTarget}\n${error}`);

style: options.style ?? (await resolveProperty?.('style')) ?? 'none',
cssModules: options.cssModules ?? (await resolveProperty?.('cssModules')) ?? false,
};
}
function validateOptions(options: Required<CreateComponentOption>): void {
/**
* Validate CSS Modules
*/
if (options.cssModules && ['css', 'scss'].includes(options.style) === false) {
throw new Error(`Cannot use CSS Modules with style "${options.style}", only "css" and "scss" are supported.`);
}
}

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

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