simple-scaffold 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +36 -26
  2. package/package.json +2 -1
package/README.md CHANGED
@@ -1,16 +1,13 @@
1
1
  # simple-scaffold
2
2
 
3
- Simple Scaffold allows you to create your structured files based on templates.
3
+ Simple Scaffold allows you to generate any set of files in the easiest way possible with simple commands.
4
4
 
5
- Simply organize your commonly-created files in their original structure, and replace any variable
6
- values (such as component or app name) inside the paths or contents of the files with tokens to be
7
- populated upon scaffolding.
5
+ It is completely framework agnostic so you can use it for anything from a few simple files to an
6
+ entire app boilerplate setup.
8
7
 
9
- Then, run Simple Scaffold and it will generate your files for you in the desired structure,
10
- with file names and contents that contain your dynamic information.
11
-
12
- It's a simple way to easily create reusable components, common class files to start writing from,
13
- or even entire app structures.
8
+ Simply organize your commonly-created files in their original structure, and running Simple Scaffold
9
+ will copy the files to the output path, while replacing values (such as component or app name, or
10
+ other custom data) inside the paths or contents of the files using Handlebars.js syntax.
14
11
 
15
12
  ## Install
16
13
 
@@ -22,7 +19,7 @@ npm install [-g] simple-scaffold
22
19
  # yarn
23
20
  yarn [global] add simple-scaffold
24
21
  # run without installing
25
- npx simple-scaffold <...args>
22
+ npx simple-scaffold@latest <...args>
26
23
  ```
27
24
 
28
25
  ## Use as a command line tool
@@ -81,10 +78,8 @@ You can also add this as a script in your `package.json`:
81
78
 
82
79
  ```json
83
80
  {
84
- ...
85
81
  "scripts": {
86
- ...
87
- "scaffold": "yarn simple-scaffold --templates scaffolds/component/**/* --output src/components --data '{\"myProp\": \"propName\", \"myVal\": \"123\"}'"
82
+ "scaffold": "npx simple-scaffold@latest -t scaffolds/component/**/* -o src/components -d '{\"myProp\": \"propName\", \"myVal\": 123}'"
88
83
  }
89
84
  }
90
85
  ```
@@ -148,15 +143,29 @@ transformed files in the output directory.
148
143
  The data available for the template parser is the data you pass to the `data` config option (or
149
144
  `--data` argument in CLI).
150
145
 
146
+ For example, using the following command:
147
+
148
+ ```bash
149
+ npx simple-scaffold@latest --templates templates/components/{{name}}.jsx --output src/components -create-sub-folder true MyComponent
150
+ ```
151
+
152
+ Will output a file with the path:
153
+
154
+ ```plaintext
155
+ <working_dir>/src/components/MyComponent.jsx
156
+ ```
157
+
158
+ The contents of the file will be transformed in a similar fashion.
159
+
151
160
  Your `data` will be pre-populated with the following:
152
161
 
153
162
  - `{{Name}}`: PascalCase of the component name
154
- - `{{name}}`: raw name of the component
163
+ - `{{name}}`: raw name of the component as you entered it
155
164
 
156
- > Simple-Scaffold uses [Handlebars.js](https://handlebarsjs.com/) for outputting the file contents,
157
- > see their documentation for more information on syntax.
165
+ > Simple-Scaffold uses [Handlebars.js](https://handlebarsjs.com/) for outputting the file contents.
158
166
  > Any `data` you add in the config will be available for use with their names wrapped in
159
- > `{{` and `}}`.
167
+ > `{{` and `}}`. Other Handlebars built-ins such as `each`, `if` and `with` are also supported, see
168
+ > [Handlebars.js Language Features](https://handlebarsjs.com/guide/#language-features) for more information.
160
169
 
161
170
  #### Helpers
162
171
 
@@ -169,14 +178,15 @@ Here are the built-in helpers available for use:
169
178
 
170
179
  | Helper name | Example code | Example output |
171
180
  | ----------- | ----------------------- | -------------- |
181
+ | [None] | `{{ name }}` | my name |
172
182
  | camelCase | `{{ camelCase name }}` | myName |
173
183
  | snakeCase | `{{ snakeCase name }}` | my_name |
174
184
  | startCase | `{{ startCase name }}` | My Name |
175
185
  | kebabCase | `{{ kebabCase name }}` | my-name |
176
186
  | hyphenCase | `{{ hyphenCase name }}` | my-name |
177
187
  | pascalCase | `{{ pascalCase name }}` | MyName |
178
- | upperCase | `{{ upperCase name }}` | MYNAME |
179
- | lowerCase | `{{ lowerCase name }}` | myname |
188
+ | upperCase | `{{ upperCase name }}` | MY NAME |
189
+ | lowerCase | `{{ lowerCase name }}` | my name |
180
190
 
181
191
  > These helpers are available for any data property, not exclusive to `name`.
182
192
 
@@ -220,12 +230,12 @@ simple-scaffold MyComponent \
220
230
 
221
231
  #### Contents of `project/scaffold/{{Name}}.jsx`
222
232
 
223
- ```js
224
- const React = require('react')
233
+ ```typescriptreact
234
+ import React from 'react'
225
235
 
226
- module.exports = function {{Name}}(props) {
236
+ export default {{camelCase ame}}: React.FC = (props) => {
227
237
  return (
228
- <div className="{{className}}">{{Name}} Component</div>
238
+ <div className="{{className}}">{{camelCase name}} Component</div>
229
239
  )
230
240
  }
231
241
  ```
@@ -255,10 +265,10 @@ With `createSubFolder = false`:
255
265
 
256
266
  #### Contents of `project/scaffold/MyComponent/MyComponent.jsx`
257
267
 
258
- ```js
259
- const React = require("react")
268
+ ```typescriptreact
269
+ import React from 'react'
260
270
 
261
- module.exports = function MyComponent(props) {
271
+ export default MyComponent: React.FC = (props) => {
262
272
  return (
263
273
  <div className="myClassName">MyComponent Component</div>
264
274
  )
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "simple-scaffold",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Create files based on templates",
5
5
  "repository": "https://github.com/chenasraf/simple-scaffold.git",
6
6
  "author": "Chen Asraf <inbox@casraf.com>",
7
7
  "license": "MIT",
8
8
  "main": "index.js",
9
9
  "bin": "cmd.js",
10
+ "keywords": ["javascript", "cli", "template", "files", "typescript", "generator", "scaffold", "file", "scaffolding"],
10
11
  "scripts": {
11
12
  "clean": "rm -rf dist/",
12
13
  "build": "yarn clean && tsc && chmod -R +x ./dist && cp ./package.json ./README.md ./dist/",