Skip to content

Commit 61298f4

Browse files
committed
prettier
1 parent 471e565 commit 61298f4

18 files changed

+1012
-991
lines changed

.prettierrc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2-
"printWidth": 150,
3-
"singleQuote": true,
4-
"trailingComma": "es5",
52
"arrowParens": "always",
6-
"bracketSpacing": false
3+
"jsxSingleQuote": false,
4+
"printWidth": 120,
5+
"semi": true,
6+
"singleQuote": true,
7+
"tabWidth": 2,
8+
"trailingComma": "es5"
79
}

README.md

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,43 @@ $ yarn add generate-template-files
3131
3. Run `node generate.js` within Terminal (Mac) or Powershell (Win) once you've added your template files.
3232

3333
```js
34-
const {generateTemplateFiles} = require('generate-template-files');
34+
const { generateTemplateFiles } = require('generate-template-files');
3535

3636
const config = require('../package.json');
3737

3838
generateTemplateFiles([
39-
{
40-
option: 'Create Redux Store',
41-
defaultCase: '(pascalCase)',
42-
entry: {
43-
folderPath: './tools/templates/react/redux-store/',
44-
},
45-
stringReplacers: ['__store__', {question: 'Insert model name', slot: '__model__'}],
46-
output: {
47-
path: './src/stores/__store__(lowerCase)',
48-
pathAndFileNameDefaultCase: '(kebabCase)',
49-
overwrite: true,
50-
},
39+
{
40+
option: 'Create Redux Store',
41+
defaultCase: '(pascalCase)',
42+
entry: {
43+
folderPath: './tools/templates/react/redux-store/',
5144
},
52-
{
53-
option: 'Create Reduce Action',
54-
defaultCase: '(pascalCase)',
55-
entry: {
56-
folderPath: './tools/templates/react/redux-store/__store__Action.ts',
57-
},
58-
stringReplacers: ['__store__', '__model__'],
59-
dynamicReplacers: [
60-
{slot: '__version__', slotValue: config.version},
61-
{slot: '__description__', slotValue: config.description},
62-
],
63-
output: {
64-
path: './src/stores/__store__/__store__(lowerCase)/__store__(pascalCase)Action.ts',
65-
pathAndFileNameDefaultCase: '(kebabCase)',
66-
},
67-
onComplete: (results) => {
68-
console.log(`results`, results);
69-
},
45+
stringReplacers: ['__store__', { question: 'Insert model name', slot: '__model__' }],
46+
output: {
47+
path: './src/stores/__store__(lowerCase)',
48+
pathAndFileNameDefaultCase: '(kebabCase)',
49+
overwrite: true,
7050
},
51+
},
52+
{
53+
option: 'Create Reduce Action',
54+
defaultCase: '(pascalCase)',
55+
entry: {
56+
folderPath: './tools/templates/react/redux-store/__store__Action.ts',
57+
},
58+
stringReplacers: ['__store__', '__model__'],
59+
dynamicReplacers: [
60+
{ slot: '__version__', slotValue: config.version },
61+
{ slot: '__description__', slotValue: config.description },
62+
],
63+
output: {
64+
path: './src/stores/__store__/__store__(lowerCase)/__store__(pascalCase)Action.ts',
65+
pathAndFileNameDefaultCase: '(kebabCase)',
66+
},
67+
onComplete: (results) => {
68+
console.log(`results`, results);
69+
},
70+
},
7171
]);
7272
```
7373

@@ -89,16 +89,16 @@ The `generateTemplateFiles` function takes an array of `IConfigItem` items.
8989

9090
#### `IConfigItem`
9191

92-
- `option` - The name of the option to choose when asked.
93-
- `defaultCase` - The default [Case Converters](#case-converters) to use with the [Replacer Slots](#replacer-slots-or-ireplacerslotquestion) in the template files. Default is `(noCase)`.
94-
- `entry.folderPath` - Path to a folder of files or a single template file.
92+
- `option` - The name of the option to choose when asked.
93+
- `defaultCase` - The default [Case Converters](#case-converters) to use with the [Replacer Slots](#replacer-slots-or-ireplacerslotquestion) in the template files. Default is `(noCase)`.
94+
- `entry.folderPath` - Path to a folder of files or a single template file.
9595

96-
- `stringReplacers` - An array of [Replacer Slots](#replacer-slots-or-ireplacerslotquestion) used to replace content in the designated `entry.folderPath`.
97-
- `dynamicReplacers` - (Optional) An array of IReplacer used to replace content in the designated `entry.folderPath`.
98-
- `output.path` - The desired output path for generated files. [Case Converters](#case-converters) and [Replacer Slots](#replacer-slots-or-ireplacerslotquestion) can be used to make the path somewhat dynamic.
99-
- `output.pathAndFileNameDefaultCase` - The [Case Converters](#case-converters) to use for the file path and file name(s).
100-
- `output.overwrite` - (Optional) When `true` it will overwrite any files that are named the same.
101-
- `onComplete` - (Optional) Takes a callback function that is called once the file(s) have been outputted. A [IResults](#iresults) object will be passed to the callback.
96+
- `stringReplacers` - An array of [Replacer Slots](#replacer-slots-or-ireplacerslotquestion) used to replace content in the designated `entry.folderPath`.
97+
- `dynamicReplacers` - (Optional) An array of IReplacer used to replace content in the designated `entry.folderPath`.
98+
- `output.path` - The desired output path for generated files. [Case Converters](#case-converters) and [Replacer Slots](#replacer-slots-or-ireplacerslotquestion) can be used to make the path somewhat dynamic.
99+
- `output.pathAndFileNameDefaultCase` - The [Case Converters](#case-converters) to use for the file path and file name(s).
100+
- `output.overwrite` - (Optional) When `true` it will overwrite any files that are named the same.
101+
- `onComplete` - (Optional) Takes a callback function that is called once the file(s) have been outputted. A [IResults](#iresults) object will be passed to the callback.
102102

103103
###### Example
104104

@@ -128,9 +128,9 @@ The `generateTemplateFiles` function takes an array of `IConfigItem` items.
128128

129129
Below is an example of what you receive from the `onComplete` callback. It has the output path, list of files created and the [Replacer Slots](#replacer-slots-or-ireplacerslotquestion) with the value entered.
130130

131-
- `output.path` - The file(s) output path
132-
- `output.files` - List of files created
133-
- `stringReplacers` - List of [Replacer Slots](#replacer-slots-or-ireplacerslotquestion); name and values entered during the setup process
131+
- `output.path` - The file(s) output path
132+
- `output.files` - List of files created
133+
- `stringReplacers` - List of [Replacer Slots](#replacer-slots-or-ireplacerslotquestion); name and values entered during the setup process
134134

135135
###### Example data you would get from the onComplete callback
136136

@@ -166,14 +166,14 @@ Below is an example of what you receive from the `onComplete` callback. It has t
166166
[Replacer Slots](#replacer-slots-or-ireplacerslotquestion) are unique string value(s) to be replaced by the generator. An array of string values and/or `IReplacerSlotQuestion` objects can be used.
167167

168168
```javascript
169-
stringReplacers: ['__store__', {question: 'Insert model name', slot: '__model__'}];
169+
stringReplacers: ['__store__', { question: 'Insert model name', slot: '__model__' }];
170170
```
171171

172172
Replacer slot can be any string value you want to use. You can use something like this in your template files and/or in the file path names.
173173

174-
- `~replacerSlot~`
175-
- `{{something else}}`
176-
- `__AnythingYouWant__`
174+
- `~replacerSlot~`
175+
- `{{something else}}`
176+
- `__AnythingYouWant__`
177177

178178
#### `IReplacerSlotQuestion`
179179

@@ -183,8 +183,8 @@ Below is an example of a `IReplacerSlotQuestion`
183183
{question: 'Insert model name', slot: '__model__'}
184184
```
185185

186-
- `question` - The question to ask the use what value should be used for the replacer `slot`
187-
- `slot` - The string value for the [Replacer Slots](#replacer-slots-or-ireplacerslotquestion)
186+
- `question` - The question to ask the use what value should be used for the replacer `slot`
187+
- `slot` - The string value for the [Replacer Slots](#replacer-slots-or-ireplacerslotquestion)
188188

189189
#### Dynamic Replacer Slots
190190

@@ -202,9 +202,9 @@ dynamicReplacers: [
202202

203203
Example
204204

205-
- In the generator template `__replacerSlot__` is appended by the `(pascalCase)` converter such as `__replacerSlot__(pascalCase)`.
206-
- When the generator is ran, the string `"product reducer"` is provided for `__replacerSlot__`.
207-
- As a result, the converter will produce `ProductReducer`.
205+
- In the generator template `__replacerSlot__` is appended by the `(pascalCase)` converter such as `__replacerSlot__(pascalCase)`.
206+
- When the generator is ran, the string `"product reducer"` is provided for `__replacerSlot__`.
207+
- As a result, the converter will produce `ProductReducer`.
208208

209209
Here is the string `Lives down BY the River` with each of the converters:
210210

@@ -222,34 +222,34 @@ Here is the string `Lives down BY the River` with each of the converters:
222222

223223
One Rule: no spaces between the [Replacer Slots](#replacer-slots-or-ireplacerslotquestion) and [Case Converters](#case-converters). If there is a space, [Case Converters](#case-converters) will not work.
224224

225-
- :white_check_mark: `__name__(camelCase)`
226-
- :warning: `__name__ (camelCase)`
225+
- :white_check_mark: `__name__(camelCase)`
226+
- :warning: `__name__ (camelCase)`
227227

228228
## Command Line Usage
229229

230230
You can use `generate-template-files` with the command line to generate your template files.
231231

232232
```js
233233
// generate.js
234-
const {generateTemplateFilesCommandLine} = require('generate-template-files');
234+
const { generateTemplateFilesCommandLine } = require('generate-template-files');
235235

236236
generateTemplateFilesCommandLine([
237-
{
238-
option: 'Create Reduce Action',
239-
defaultCase: '(pascalCase)',
240-
entry: {
241-
folderPath: './tools/templates/react/redux-store/__store__Action.ts',
242-
},
243-
stringReplacers: ['__store__', '__model__'],
244-
dynamicReplacers: [
245-
{slot: '__version__', slotValue: config.version},
246-
{slot: '__description__', slotValue: config.description},
247-
],
248-
output: {
249-
path: './src/stores/__store__/__store__(lowerCase)/__store__(pascalCase)Action.ts',
250-
pathAndFileNameDefaultCase: '(kebabCase)',
251-
},
237+
{
238+
option: 'Create Reduce Action',
239+
defaultCase: '(pascalCase)',
240+
entry: {
241+
folderPath: './tools/templates/react/redux-store/__store__Action.ts',
242+
},
243+
stringReplacers: ['__store__', '__model__'],
244+
dynamicReplacers: [
245+
{ slot: '__version__', slotValue: config.version },
246+
{ slot: '__description__', slotValue: config.description },
247+
],
248+
output: {
249+
path: './src/stores/__store__/__store__(lowerCase)/__store__(pascalCase)Action.ts',
250+
pathAndFileNameDefaultCase: '(kebabCase)',
252251
},
252+
},
253253
]);
254254
```
255255

@@ -267,11 +267,11 @@ node ./tools/generate.js create-reduce-action __store__=some-name __model__=some
267267

268268
**Command LIne Script Overview**
269269

270-
- `node ./tools/generate.js` - Runs the `generate-template-files` library
271-
- `create-reduce-action` - The template name; It uses the same option name in the [IConfigItem](#iconfigitem) but converts all options names to kebab-case. For example `option: 'Create Reduce Action'` will be converted to `create-reduce-action` when using the command line
272-
- `__store__=some-name` - Are [Replacer Slots](#replacer-slots-or-ireplacerslotquestion) and will be converted to `{ slot: "__store__", slotValue: "some-name" }`
273-
- `--outputpath=./src/here` - Will override the `output.path` in the [IConfigItem](#iconfigitem)
274-
- `--overwrite` - Will overwrite files if the files already exists
270+
- `node ./tools/generate.js` - Runs the `generate-template-files` library
271+
- `create-reduce-action` - The template name; It uses the same option name in the [IConfigItem](#iconfigitem) but converts all options names to kebab-case. For example `option: 'Create Reduce Action'` will be converted to `create-reduce-action` when using the command line
272+
- `__store__=some-name` - Are [Replacer Slots](#replacer-slots-or-ireplacerslotquestion) and will be converted to `{ slot: "__store__", slotValue: "some-name" }`
273+
- `--outputpath=./src/here` - Will override the `output.path` in the [IConfigItem](#iconfigitem)
274+
- `--overwrite` - Will overwrite files if the files already exists
275275

276276
[npm-url]: https://npmjs.org/package/generate-template-files
277277
[downloads-img]: http://img.shields.io/npm/dm/generate-template-files.svg?style=flat-square

jest.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// https://github.com/kulshekhar/ts-jest
22

33
module.exports = {
4-
verbose: false,
5-
preset: 'ts-jest',
6-
testEnvironment: 'node',
7-
roots: ['<rootDir>/src'],
8-
collectCoverageFrom: ['src/**/*.ts', '!src/**/*.{test,spec,d}.ts'],
4+
verbose: false,
5+
preset: 'ts-jest',
6+
testEnvironment: 'node',
7+
roots: ['<rootDir>/src'],
8+
collectCoverageFrom: ['src/**/*.ts', '!src/**/*.{test,spec,d}.ts'],
99
};

rollup.config.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,37 @@ import pkg from './package.json';
66
const extensions = ['.js', '.jsx', '.ts', '.tsx'];
77

88
export default {
9-
input: './src/index.ts',
10-
11-
// Specify here external modules which you don't want to include in your bundle (for instance: 'lodash', 'moment' etc.)
12-
// https://rollupjs.org/guide/en#external-e-external
13-
external: [...Object.keys(pkg.dependencies || {})],
14-
15-
plugins: [
16-
// Allows node_modules resolution
17-
resolve({extensions}),
18-
19-
// Allow bundling cjs modules. Rollup doesn't understand cjs
20-
commonjs(),
21-
22-
// Compile TypeScript/JavaScript files
23-
babel({
24-
extensions,
25-
include: ['src/**/*'],
26-
runtimeHelpers: true,
27-
}),
28-
],
29-
30-
output: [
31-
{
32-
file: pkg.main,
33-
format: 'cjs',
34-
},
35-
{
36-
file: pkg.module,
37-
format: 'es',
38-
},
39-
],
9+
input: './src/index.ts',
10+
11+
// Specify here external modules which you don't want to include in your bundle (for instance: 'lodash', 'moment' etc.)
12+
// https://rollupjs.org/guide/en#external-e-external
13+
external: [...Object.keys(pkg.dependencies || {})],
14+
15+
plugins: [
16+
// Allows node_modules resolution
17+
resolve({ extensions }),
18+
19+
// Allow bundling cjs modules. Rollup doesn't understand cjs
20+
commonjs(),
21+
22+
// Compile TypeScript/JavaScript files
23+
babel({
24+
extensions,
25+
include: ['src/**/*'],
26+
runtimeHelpers: true,
27+
}),
28+
],
29+
30+
output: [
31+
{
32+
file: pkg.main,
33+
format: 'cjs',
34+
},
35+
{
36+
file: pkg.module,
37+
format: 'es',
38+
},
39+
],
4040
};
4141

4242
// https://github.com/a-tarasyuk/rollup-typescript-babel

0 commit comments

Comments
 (0)