Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit 207d33e

Browse files
authored
Merge pull request #60 from react-boilerplate/fix-template-generator-script
Fix template generator script
2 parents 678b47b + 962846c commit 207d33e

File tree

8 files changed

+512
-26
lines changed

8 files changed

+512
-26
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Global owners
2+
* @Can-Sahin

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- xvfb
99

1010
script:
11-
# - node ./internals/scripts/generate-templates-for-linting
11+
- node ./internals/scripts/generate-templates-for-linting
1212
- npm test -- --maxWorkers=4
1313
- npm run build
1414

internals/generators/container/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ module.exports = {
7878
];
7979

8080
// If component wants tests
81-
if (data.wantMessages) {
81+
if (data.wantTests) {
8282
actions.push({
8383
type: 'add',
84-
path: '../../app/containers/{{properCase name}}/tests/index.test.ts',
84+
path: '../../app/containers/{{properCase name}}/tests/index.test.tsx',
8585
templateFile: './container/test.tsx.hbs',
8686
abortOnFail: true,
8787
});

internals/generators/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ const componentGenerator = require('./component/index.js');
1111
const containerGenerator = require('./container/index.js');
1212
const languageGenerator = require('./language/index.js');
1313

14+
/**
15+
* Every generated backup file gets this extension
16+
* @type {string}
17+
*/
18+
const BACKUPFILE_EXTENSION = 'rbgen';
19+
20+
1421
module.exports = plop => {
1522
plop.setGenerator('component', componentGenerator);
1623
plop.setGenerator('container', containerGenerator);
@@ -38,4 +45,22 @@ module.exports = plop => {
3845
exec(`npm run prettify -- "${folderPath}"`);
3946
return folderPath;
4047
});
48+
plop.setActionType('backup', (answers, config) => {
49+
fs.copyFileSync(
50+
path.join(__dirname, config.path, config.file),
51+
path.join(
52+
__dirname,
53+
config.path,
54+
`${config.file}.${BACKUPFILE_EXTENSION}`,
55+
),
56+
'utf8',
57+
);
58+
return path.join(
59+
__dirname,
60+
config.path,
61+
`${config.file}.${BACKUPFILE_EXTENSION}`,
62+
);
63+
});
4164
};
65+
66+
module.exports.BACKUPFILE_EXTENSION = BACKUPFILE_EXTENSION;

internals/generators/language/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ module.exports = {
4242
actions.push({
4343
type: 'backup',
4444
path: '../../app',
45-
file: 'i18n.js',
45+
file: 'i18n.ts',
4646
});
4747

4848
actions.push({
4949
type: 'backup',
5050
path: '../../app',
51-
file: 'app.js',
51+
file: 'app.tsx',
5252
});
5353
}
5454

internals/scripts/generate-templates-for-linting.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ function reportErrors(reason) {
103103
function runLintingOnDirectory(relativePath) {
104104
return new Promise((resolve, reject) => {
105105
shell.exec(
106-
`npm run lint:eslint "app/${relativePath}/**/**.js"`,
106+
// dont run typescript typechecking here because CLI doesn't support glob pattern
107+
`npm run lint:tslint "app/${relativePath}/**/**.ts*"`,
107108
{
108109
silent: true,
109110
},

0 commit comments

Comments
 (0)