Skip to content

Commit 171c39b

Browse files
author
Jeppe Reinhold
committed
initial files - plop works
1 parent 92d9aed commit 171c39b

File tree

9 files changed

+343
-0
lines changed

9 files changed

+343
-0
lines changed

Diff for: .gitignore

+172
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# ONLY FOR THIS BOILERPLATE - REMOVE WHEN USING OUTSIDE OF THIS REPO
2+
yarn.lock
3+
.idea/
4+
5+
# Created by .ignore support plugin (hsz.mobi)
6+
### macOS template
7+
# General
8+
.DS_Store
9+
.AppleDouble
10+
.LSOverride
11+
12+
# Icon must end with two \r
13+
Icon
14+
15+
# Thumbnails
16+
._*
17+
18+
# Files that might appear in the root of a volume
19+
.DocumentRevisions-V100
20+
.fseventsd
21+
.Spotlight-V100
22+
.TemporaryItems
23+
.Trashes
24+
.VolumeIcon.icns
25+
.com.apple.timemachine.donotpresent
26+
27+
# Directories potentially created on remote AFP share
28+
.AppleDB
29+
.AppleDesktop
30+
Network Trash Folder
31+
Temporary Items
32+
.apdisk
33+
### Windows template
34+
# Windows thumbnail cache files
35+
Thumbs.db
36+
ehthumbs.db
37+
ehthumbs_vista.db
38+
39+
# Dump file
40+
*.stackdump
41+
42+
# Folder config file
43+
Desktop.ini
44+
45+
# Recycle Bin used on file shares
46+
$RECYCLE.BIN/
47+
48+
# Windows Installer files
49+
*.cab
50+
*.msi
51+
*.msm
52+
*.msp
53+
54+
# Windows shortcuts
55+
*.lnk
56+
### VisualStudioCode template
57+
.vscode/*
58+
!.vscode/settings.json
59+
!.vscode/tasks.json
60+
!.vscode/launch.json
61+
!.vscode/extensions.json
62+
### Node template
63+
# Logs
64+
logs
65+
*.log
66+
npm-debug.log*
67+
yarn-debug.log*
68+
yarn-error.log*
69+
70+
# Runtime data
71+
pids
72+
*.pid
73+
*.seed
74+
*.pid.lock
75+
76+
# Directory for instrumented libs generated by jscoverage/JSCover
77+
lib-cov
78+
79+
# Coverage directory used by tools like istanbul
80+
coverage
81+
82+
# nyc test coverage
83+
.nyc_output
84+
85+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
86+
.grunt
87+
88+
# Bower dependency directory (https://bower.io/)
89+
bower_components
90+
91+
# node-waf configuration
92+
.lock-wscript
93+
94+
# Compiled binary addons (https://nodejs.org/api/addons.html)
95+
build/Release
96+
97+
# Dependency directories
98+
node_modules/
99+
jspm_packages/
100+
101+
# Typescript v1 declaration files
102+
typings/
103+
104+
# Optional npm cache directory
105+
.npm
106+
107+
# Optional eslint cache
108+
.eslintcache
109+
110+
# Optional REPL history
111+
.node_repl_history
112+
113+
# Output of 'npm pack'
114+
*.tgz
115+
116+
# Yarn Integrity file
117+
.yarn-integrity
118+
119+
# dotenv environment variables file
120+
.env
121+
122+
### JetBrains template
123+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
124+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
125+
126+
# User-specific stuff:
127+
.idea/**/workspace.xml
128+
.idea/**/tasks.xml
129+
.idea/dictionaries
130+
131+
# Sensitive or high-churn files:
132+
.idea/**/dataSources/
133+
.idea/**/dataSources.ids
134+
.idea/**/dataSources.xml
135+
.idea/**/dataSources.local.xml
136+
.idea/**/sqlDataSources.xml
137+
.idea/**/dynamic.xml
138+
.idea/**/uiDesigner.xml
139+
140+
# Gradle:
141+
.idea/**/gradle.xml
142+
.idea/**/libraries
143+
144+
# CMake
145+
cmake-build-debug/
146+
147+
# Mongo Explorer plugin:
148+
.idea/**/mongoSettings.xml
149+
150+
## File-based project format:
151+
*.iws
152+
153+
## Plugin-specific files:
154+
155+
# IntelliJ
156+
out/
157+
158+
# mpeltonen/sbt-idea plugin
159+
.idea_modules/
160+
161+
# JIRA plugin
162+
atlassian-ide-plugin.xml
163+
164+
# Cursive Clojure plugin
165+
.idea/replstate.xml
166+
167+
# Crashlytics plugin (for Android Studio and IntelliJ)
168+
com_crashlytics_export_strings.xml
169+
crashlytics.properties
170+
crashlytics-build.properties
171+
fabric.properties
172+

Diff for: package.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"version": "0.1.0",
3+
"devDependencies": {
4+
"prettier": "latest",
5+
"tslint": "latest",
6+
"jest": "latest",
7+
"plop": "latest",
8+
"source-map-explorer": "latest",
9+
"husky": "latest1",
10+
"lint-staged": "latest"
11+
},
12+
"scripts": {
13+
"lint": "tslint 'src/**/*.{ts,tsx}'",
14+
"format": "prettier --write \"{./*.{ts,js,json},src/**/*.{js,ts,tsx}}\"",
15+
"build": "LOLOLOL",
16+
"test": "LOLOLOL",
17+
"analyze": "source-map-explorer build/static/js/main.*",
18+
"analyze:ci": "source-map-explorer --html build/static/js/main.* > ./size-analysis.html",
19+
"precommit": "lint-staged",
20+
"postcommit": "git reset"
21+
},
22+
"prettier": {
23+
"singleQuote": true,
24+
"trailingComma": "all",
25+
"useTabs": true,
26+
"printWidth": 100
27+
},
28+
"lint-staged": {
29+
"{./*.{ts,js,json},src/**/*.{js,ts,tsx}}": [
30+
"prettier --print-width 100 --write --use-tabs --single-quote --trailing-comma all",
31+
"git add"
32+
]
33+
}
34+
}

Diff for: plopfile.js

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
module.exports = function(plop) {
2+
// create your generators here
3+
4+
plop.addHelper('splitOnCaps', splitOnCaps);
5+
6+
plop.setGenerator('component', {
7+
description: 'this generates an entirely new component',
8+
prompts: [
9+
{
10+
type: 'input',
11+
name: 'name',
12+
message: 'the name of the component (PascalCase, no Component at the end)',
13+
validate: isPascalCased,
14+
},
15+
{
16+
type: 'confirm',
17+
name: 'isFetching',
18+
message: 'Will the component fetch data over the network?',
19+
},
20+
],
21+
actions: (answers) => {
22+
const fetching = answers.isFetching ? '.fetching' : '';
23+
24+
return [
25+
{
26+
type: 'add',
27+
path:
28+
'src/components/{{dashCase name}}.ts',
29+
templateFile: `templates/component${fetching}.hsb`,
30+
},
31+
{
32+
type: 'modify',
33+
path: 'src/index.ts',
34+
pattern: /(import)/i,
35+
template:
36+
"import { {{camelCase name}}Component } from './components/{{dashCase name}}';\n$1",
37+
},
38+
{
39+
type: 'modify',
40+
path: 'src/index.ts',
41+
pattern: /(\/\/log components)/i,
42+
template:
43+
"$1\nconsole.log({{camelCase name}}Component('cool value'));",
44+
},
45+
() => `Component creation succesful!`,
46+
];
47+
},
48+
});
49+
};
50+
51+
/** Helper Functions */
52+
const isPascalCased = input => {
53+
if (isUpperCase(input.charAt(0))) {
54+
return true;
55+
}
56+
return `string ${input} must be PascalCased.`;
57+
};
58+
59+
const isUpperCase = myString => {
60+
return myString === myString.toUpperCase();
61+
};
62+
63+
const splitOnCaps = txt => {
64+
return txt.split(/(?=[A-Z])/).join(' ');
65+
};

Diff for: src/components/example.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const exampleComponent = (exampleValue: string) => {
2+
return 'This is the ExampleComponent and has the value ' + exampleValue;
3+
};

Diff for: src/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { exampleComponent } from './components/example';
2+
3+
//log components
4+
console.log(exampleComponent('cool value'));

Diff for: templates/component.fetching.hsb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const {{camelCase name}}Component = ( {{camelCase name}}Value: string) => {
2+
return 'This is the {{name}}Component and is fetching nice things using ' + {{camelCase name}}Value;
3+
};

Diff for: templates/component.hsb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const {{camelCase name}}Component = ( {{camelCase name}}Value: string) => {
2+
return 'This is the {{name}}Component and has the value ' + {{camelCase name}}Value;
3+
};

Diff for: tsconfig.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "build/",
4+
"module": "commonjs",
5+
"experimentalDecorators": true,
6+
"target": "es5",
7+
"lib": ["es6", "dom"],
8+
"sourceMap": true,
9+
"allowJs": true,
10+
"jsx": "react",
11+
"moduleResolution": "node",
12+
"forceConsistentCasingInFileNames": true,
13+
"strict": true
14+
},
15+
"exclude": [
16+
"node_modules",
17+
"build",
18+
"scripts",
19+
"acceptance-tests",
20+
"webpack",
21+
"jest",
22+
"src/setupTests.ts"
23+
]
24+
}

Diff for: tslint.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"extends": ["tslint-react"],
3+
"rules": {
4+
"class-name": true,
5+
"forin": true,
6+
"interface-name": [true, "never-prefix"],
7+
"jsx-no-lambda": false,
8+
"jsx-no-multiline-js": false,
9+
"jsx-wrap-multiline": false,
10+
"label-position": true,
11+
"member-ordering": [
12+
true,
13+
"public-before-private",
14+
"static-before-instance",
15+
"variables-before-functions"
16+
],
17+
"no-arg": true,
18+
"no-bitwise": true,
19+
"no-default-export": true,
20+
"no-console": [true],
21+
"no-construct": true,
22+
"no-debugger": true,
23+
"no-duplicate-variable": true,
24+
"no-empty": true,
25+
"no-eval": true,
26+
"no-string-literal": true,
27+
"no-switch-case-fall-through": true,
28+
"radix": true,
29+
"switch-default": true,
30+
"triple-equals": [true, "allow-null-check"],
31+
"typedef": [true, "parameter", "property-declaration"],
32+
"variable-name": false,
33+
"jsx-alignment": false
34+
}
35+
}

0 commit comments

Comments
 (0)