@anephenix/rcg
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -42,4 +42,3 @@ // This file tests the rcg binary | ||
const command = `./bin/rcg ${title}`; | ||
const { stdout, stderr } = await exec(command); | ||
assert.equal(stdout, ''); | ||
const { stderr } = await exec(command); | ||
assert.equal(stderr, ''); | ||
@@ -96,3 +95,8 @@ const folderExists = await exists(folderPath); | ||
recordedStdout, | ||
`Using configuration settings found at ${exampleConfigFilePath}\n` | ||
`Using configuration settings found at ${exampleConfigFilePath} | ||
Created files:\n | ||
/Users/pauljensen/Work/anephenix/rcg/components/my-test-component/MyTestComponent.jsx | ||
/Users/pauljensen/Work/anephenix/rcg/components/my-test-component/MyTestComponent.scss | ||
/Users/pauljensen/Work/anephenix/rcg/components/my-test-component/MyTestComponent.test.jsx | ||
` | ||
); | ||
@@ -138,4 +142,3 @@ assert.equal(recordedStderr, ''); | ||
const command = `./bin/rcg ${title} --directory ${directory}`; | ||
const { stdout, stderr } = await exec(command); | ||
assert.equal(stdout, ''); | ||
const { stderr } = await exec(command); | ||
assert.equal(stderr, ''); | ||
@@ -170,4 +173,3 @@ const folderExists = await exists(folderPath); | ||
const command = `./bin/rcg ${title} --jsExtension jsx`; | ||
const { stdout, stderr } = await exec(command); | ||
assert.equal(stdout, ''); | ||
const { stderr } = await exec(command); | ||
assert.equal(stderr, ''); | ||
@@ -198,4 +200,3 @@ const folderExists = await exists(folderPath); | ||
const command = `./bin/rcg ${title} --cssExtension style.js`; | ||
const { stdout, stderr } = await exec(command); | ||
assert.equal(stdout, ''); | ||
const { stderr } = await exec(command); | ||
assert.equal(stderr, ''); | ||
@@ -217,2 +218,43 @@ const folderExists = await exists(folderPath); | ||
}); | ||
describe('universal behaviour', () => { | ||
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 log all of the files that were created after executing the binary', async () => { | ||
const command = `./bin/rcg ${title}`; | ||
const { stdout, stderr } = await exec(command); | ||
assert.equal(stderr, ''); | ||
const folderExists = await exists(folderPath); | ||
assert(folderExists); | ||
const files = await readdir(folderPath); | ||
const expectedFiles = [ | ||
`${title}.js`, | ||
`${title}.scss`, | ||
`${title}.test.js`, | ||
]; | ||
for (const file of expectedFiles) { | ||
assert(files.indexOf(file) !== -1); | ||
} | ||
assert.equal( | ||
stdout, | ||
`Created files: | ||
${path.join(folderPath, expectedFiles[0])} | ||
${path.join(folderPath, expectedFiles[1])} | ||
${path.join(folderPath, expectedFiles[2])} | ||
` | ||
); | ||
}); | ||
}); | ||
}); |
@@ -23,3 +23,3 @@ const assert = require('assert'); | ||
it('should generate a boilerplate for a react component, given a name and a containing folder', async () => { | ||
await generateComponent(title, srcFolderPath); | ||
const filesCreated = await generateComponent(title, srcFolderPath); | ||
const folderExists = await exists(folderPath); | ||
@@ -39,3 +39,11 @@ assert(folderExists); | ||
assert(styleExists); | ||
assert.deepEqual( | ||
[ | ||
path.join(folderPath, `${title}.js`), | ||
path.join(folderPath, `${title}.scss`), | ||
path.join(folderPath, `${title}.test.js`), | ||
], | ||
filesCreated | ||
); | ||
}); | ||
}); |
# CHANGELOG | ||
### 0.0.9 - Thursday 21st May, 2020 | ||
- Added a way to log what files are created by RCG on the CLI | ||
### 0.0.8 - Sunday 12th April, 2020 | ||
@@ -4,0 +8,0 @@ |
@@ -20,3 +20,3 @@ // NPM Dependencies | ||
const folderName = to.slug(componentName); | ||
await generateComponentFiles({ | ||
const filesCreated = await generateComponentFiles({ | ||
title, | ||
@@ -30,4 +30,5 @@ folderName, | ||
}); | ||
return filesCreated; | ||
}; | ||
module.exports = generateComponent; |
@@ -14,3 +14,4 @@ // NPM Dependencies | ||
const filePath = path.join(folderPath, fileName); | ||
return await writeFile(filePath, fileContent); | ||
await writeFile(filePath, fileContent); | ||
return filePath; | ||
}; | ||
@@ -17,0 +18,0 @@ |
@@ -34,3 +34,4 @@ // NPM Dependencies | ||
await mkdir(folderPath); | ||
await generateStyleFile({ | ||
const filesCreated = []; | ||
const styleFilePath = await generateStyleFile({ | ||
title, | ||
@@ -42,3 +43,3 @@ folderName, | ||
}); | ||
await generateComponentFile({ | ||
const componentFilePath = await generateComponentFile({ | ||
title, | ||
@@ -51,3 +52,3 @@ folderName, | ||
}); | ||
await generateTestFile({ | ||
const testFilePath = await generateTestFile({ | ||
title, | ||
@@ -58,2 +59,6 @@ folderName, | ||
}); | ||
filesCreated.push(componentFilePath); | ||
filesCreated.push(styleFilePath); | ||
filesCreated.push(testFilePath); | ||
return filesCreated; | ||
}; | ||
@@ -60,0 +65,0 @@ |
{ | ||
"name": "@anephenix/rcg", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "React Component Generator", | ||
@@ -24,14 +24,15 @@ "main": "index.js", | ||
"devDependencies": { | ||
"coveralls": "^3.0.11", | ||
"eslint": "^6.8.0", | ||
"eslint-plugin-jest": "^23.8.2", | ||
"jest": "^25.3.0", | ||
"coveralls": "^3.1.0", | ||
"eslint": "^7.0.0", | ||
"eslint-plugin-jest": "^23.13.1", | ||
"jest": "^26.0.1", | ||
"jsdoc": "^3.6.4", | ||
"npm-upgrade": "^2.0.3", | ||
"pre-commit": "^1.2.2", | ||
"prettier": "^2.0.4" | ||
"prettier": "^2.0.5" | ||
}, | ||
"dependencies": { | ||
"commander": "^5.0.0", | ||
"commander": "^5.1.0", | ||
"to-case": "^2.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41079
977
8
Updatedcommander@^5.1.0