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

@anephenix/rcg

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anephenix/rcg - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

42

__tests__/bin/rcg.test.js

@@ -8,3 +8,10 @@ // This file tests the rcg binary

// File Dependencies
const { exists, readdir, exec, writeFile, unlink } = require('../helpers');
const {
exists,
readdir,
exec,
readFile,
writeFile,
unlink,
} = require('../helpers');
const { version } = require('../../package.json');

@@ -173,2 +180,35 @@

});
describe('--cssExtension', () => {
const title = 'MyTestComponent';
const folderName = 'my-test-component';
const folderPath = path.join(
process.cwd(),
'src',
'components',
folderName
);
beforeEach(async () => await seed(['src', 'components']));
afterEach(async () => await cleanup('src'));
it('should create a component with a custom file extension on the end', async () => {
const command = `./bin/rcg ${title} --cssExtension style.js`;
const { stdout, stderr } = await exec(command);
assert.equal(stdout, '');
assert.equal(stderr, '');
const folderExists = await exists(folderPath);
assert(folderExists);
const files = await readdir(folderPath);
const expectedFiles = [`${title}.style.js`];
for (const file of expectedFiles) {
assert(files.indexOf(file) !== -1);
}
const componentFile = path.join(folderPath, `${title}.js`);
const componentFileContent = await readFile(componentFile, 'utf8');
assert(
componentFileContent.match(`import './${title}.style.js';`) !==
null
);
});
});
});

10

__tests__/lib/generators/index.test.js

@@ -62,3 +62,3 @@ // NPM Dependencies

assert.equal(
getFileContentForComponent(title, folderName),
getFileContentForComponent(title, folderName, null, 'scss'),
expectedComponentContent

@@ -72,4 +72,10 @@ );

const customDOM = '<div>Welcome here</div>';
const customCssExtension = 'scss';
assert.equal(
getFileContentForComponent(title, folderName, customDOM),
getFileContentForComponent(
title,
folderName,
customDOM,
customCssExtension
),
expectedComponentContentWithDom(customDOM)

@@ -76,0 +82,0 @@ );

# CHANGELOG
### 0.0.8 - Sunday 12th April, 2020
- Added support for generating files with a custom file extension
### 0.0.7 - Sunday 12th April, 2020

@@ -4,0 +8,0 @@

@@ -15,3 +15,4 @@ // NPM Dependencies

customCSS,
customJSExtension
customJSExtension,
customCssExtension
) => {

@@ -27,2 +28,3 @@ const title = to.pascal(componentName);

customJSExtension,
customCssExtension,
});

@@ -29,0 +31,0 @@ };

@@ -20,7 +20,12 @@ // NPM Dependencies

*/
const getFileContentForComponent = (title, folderName, customDOM) => {
const getFileContentForComponent = (
title,
folderName,
customDOM,
customCssExtension
) => {
let element = `<div id='${folderName}' />`;
if (customDOM) element = `<div id='${folderName}'>${customDOM}</div>`;
return `
import './${title}.scss';
import './${title}.${customCssExtension}';

@@ -64,2 +69,3 @@ const ${title} = () => (${element});

customJSExtension,
customCssExtension,
}) => {

@@ -71,3 +77,4 @@ if (!customJSExtension) customJSExtension = 'js';

folderName,
customDOM
customDOM,
customCssExtension
);

@@ -95,4 +102,5 @@ return await createFile(folderPath, fileName, fileContent);

customCSS,
customCssExtension,
}) => {
const fileName = `${title}.scss`;
const fileName = `${title}.${customCssExtension || 'scss'}`;
const fileContent = getFileContentForStyleFile(folderName, customCSS);

@@ -99,0 +107,0 @@ return await createFile(folderPath, fileName, fileContent);

@@ -30,6 +30,13 @@ // NPM Dependencies

customJSExtension,
customCssExtension,
}) => {
const folderPath = path.join(srcFolderPath, folderName);
await mkdir(folderPath);
await generateStyleFile({ title, folderName, folderPath, customCSS });
await generateStyleFile({
title,
folderName,
folderPath,
customCSS,
customCssExtension,
});
await generateComponentFile({

@@ -41,2 +48,3 @@ title,

customJSExtension,
customCssExtension,
});

@@ -43,0 +51,0 @@ await generateTestFile({

{
"name": "@anephenix/rcg",
"version": "0.0.7",
"version": "0.0.8",
"description": "React Component Generator",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -69,2 +69,10 @@ # RCG

To specify a custom file extension for the css file (e.g. .style.js), you can pass the `--cssExtension` flag:
```
npx rcg NavBar --cssExtension=style.js
```
By default, it generates a scss file. This will likely change in the future to a default pattern of css-in-js
#### via NPM

@@ -98,2 +106,3 @@

const customJSExtension = 'jsx';
const customCssExtension = 'style.js';

@@ -106,3 +115,4 @@ (async () => {

customCSS,
customJSExtension
customJSExtension,
customCssExtension
);

@@ -109,0 +119,0 @@ })();

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