Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): Scaffold errors if file name exists #88

Merged
merged 5 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions docs/cli.html
Original file line number Diff line number Diff line change
Expand Up @@ -1126,30 +1126,30 @@ <h2 id="scaffold">scaffold</h2>
<div class="col-md-5 col-sm-12 col-height docs-primary">
<blockquote>
<p>Adds a starting resource, trigger, action or search to your app.</p>
</blockquote><p> <strong>Usage:</strong> <code>zapier scaffold {resource|trigger|search|create} &quot;Name&quot;</code></p><p>The scaffold command does two general things:</p><ul>
<li>Creates a new destination file like <code>resources/contact.js</code></li>
<li>(Attempts to) import and register it inside your entry <code>index.js</code></li>
</blockquote><p><strong>Usage</strong>: <code>zapier scaffold TYPE NAME</code></p><p>The first argument should one of <code>resource|trigger|search|create</code> followed by the name of the file.</p><p>The scaffold command does two general things:</p><ul>
<li><p>Creates a new destination file like <code>resources/contact.js</code></p>
</li>
<li><p>(Attempts to) import and register it inside your entry <code>index.js</code></p>
</li>
</ul><p>You can mix and match several options to customize the created scaffold for your project.</p><blockquote>
<p>Note, we may fail to rewrite your <code>index.js</code> so you may need to handle the require and registration yourself.</p>
<p>Note, we may fail to correctly rewrite your <code>index.js</code>. You may need to write in the require and registration, but we&apos;ll provide the code you need.</p>
</blockquote><p><strong>Arguments</strong></p><ul>
<li><code>type [{resource,trigger,search,create}]</code> -- <strong>required</strong>, what type of thing are you creating</li>
<li><code>name [&quot;Some Name&quot;]</code> -- <strong>required</strong>, the name of the new thing to create</li>
<li><code>--dest={type}s/{name}</code> -- <em>optional</em>, sets the new file&apos;s path. Default is <code>{type}s/{name}</code></li>
<li><code>--entry=index.js</code> -- <em>optional</em>, where to import the new file. Default is <code>index.js</code></li>
<li>(required) <code>type</code> | undefined</li>
<li>(required) <code>name</code> | undefined</li>
</ul><p><strong>Flags</strong></p><ul>
<li><code>-d, --dest</code> | Sets the new file&apos;s path. Use this flag when you want to create a different folder structure such as <code>src/triggers/my_trigger</code> The default destination is {type}s/{name}</li>
<li><code>-e, --entry</code> | Where to import the new file Defaults to <code>index.js</code>.</li>
<li><code>-f, --force</code> | Should we overwrite an exisiting file</li>
<li><code>-d, --debug</code> | Show extra debugging output</li>
</ul><p><strong>Examples</strong></p><ul>
<li><code>zapier scaffold resource &quot;Contact&quot;</code></li>
<li><code>zapier scaffold resource &quot;Contact&quot; --entry=index.js</code></li>
<li><code>zapier scaffold resource &quot;Contag Tag&quot; --dest=resources/tag</code></li>
<li><code>zapier scaffold trigger &quot;Existing Create&quot; --force</code></li>
</ul>
</div>
<div class="col-md-7 col-sm-12 col-height docs-code">
<pre><code class="lang-bash">$ zapier scaffold resource <span class="hljs-string">&quot;Contact&quot;</span>
$ zapier scaffold resource <span class="hljs-string">&quot;Contact&quot;</span> --entry=index.js
$ zapier scaffold resource <span class="hljs-string">&quot;Contag Tag&quot;</span> --dest=resources/tag
$ zapier scaffold resource <span class="hljs-string">&quot;Tag&quot;</span> --entry=index.js --dest=resources/tag
<span class="hljs-comment"># Adding resource scaffold to your project.</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># Writing new resources/tag.js - done!</span>
<span class="hljs-comment"># Rewriting your index.js - done!</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># Finished! We did the best we could, you might gut check your files though.</span>
</code></pre>
<div class="col-md-7 col-sm-12 col-height is-empty docs-code">

</div>
</div>
</div><div class="row">
Expand Down
38 changes: 18 additions & 20 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,39 +704,37 @@ $ zapier register "Example"

## scaffold

> Adds a starting resource, trigger, action or search to your app.
> Adds a starting resource, trigger, action or search to your app.

**Usage:** `zapier scaffold {resource|trigger|search|create} "Name"`
**Usage**: `zapier scaffold TYPE NAME`

The first argument should one of `resource|trigger|search|create` followed by the name of the file.


The scaffold command does two general things:

* Creates a new destination file like `resources/contact.js`

* (Attempts to) import and register it inside your entry `index.js`

You can mix and match several options to customize the created scaffold for your project.

> Note, we may fail to rewrite your `index.js` so you may need to handle the require and registration yourself.
> Note, we may fail to correctly rewrite your `index.js`. You may need to write in the require and registration, but we'll provide the code you need.

**Arguments**
* (required) `type` | undefined
* (required) `name` | undefined

* `type [{resource,trigger,search,create}]` -- **required**, what type of thing are you creating
* `name ["Some Name"]` -- **required**, the name of the new thing to create
* `--dest={type}s/{name}` -- _optional_, sets the new file's path. Default is `{type}s/{name}`
* `--entry=index.js` -- _optional_, where to import the new file. Default is `index.js`
**Flags**
* `-d, --dest` | Sets the new file's path. Use this flag when you want to create a different folder structure such as `src/triggers/my_trigger` The default destination is {type}s/{name}
* `-e, --entry` | Where to import the new file Defaults to `index.js`.
* `-f, --force` | Should we overwrite an exisiting file
* `-d, --debug` | Show extra debugging output

```bash
$ zapier scaffold resource "Contact"
$ zapier scaffold resource "Contact" --entry=index.js
$ zapier scaffold resource "Contag Tag" --dest=resources/tag
$ zapier scaffold resource "Tag" --entry=index.js --dest=resources/tag
# Adding resource scaffold to your project.
#
# Writing new resources/tag.js - done!
# Rewriting your index.js - done!
#
# Finished! We did the best we could, you might gut check your files though.
```
**Examples**
* `zapier scaffold resource "Contact"`
* `zapier scaffold resource "Contact" --entry=index.js`
* `zapier scaffold resource "Contag Tag" --dest=resources/tag`
* `zapier scaffold trigger "Existing Create" --force`


## test
Expand Down
40 changes: 20 additions & 20 deletions packages/cli/docs/cli.html
Original file line number Diff line number Diff line change
Expand Up @@ -1126,30 +1126,30 @@ <h2 id="scaffold">scaffold</h2>
<div class="col-md-5 col-sm-12 col-height docs-primary">
<blockquote>
<p>Adds a starting resource, trigger, action or search to your app.</p>
</blockquote><p> <strong>Usage:</strong> <code>zapier scaffold {resource|trigger|search|create} &quot;Name&quot;</code></p><p>The scaffold command does two general things:</p><ul>
<li>Creates a new destination file like <code>resources/contact.js</code></li>
<li>(Attempts to) import and register it inside your entry <code>index.js</code></li>
</blockquote><p><strong>Usage</strong>: <code>zapier scaffold TYPE NAME</code></p><p>The first argument should one of <code>resource|trigger|search|create</code> followed by the name of the file.</p><p>The scaffold command does two general things:</p><ul>
<li><p>Creates a new destination file like <code>resources/contact.js</code></p>
</li>
<li><p>(Attempts to) import and register it inside your entry <code>index.js</code></p>
</li>
</ul><p>You can mix and match several options to customize the created scaffold for your project.</p><blockquote>
<p>Note, we may fail to rewrite your <code>index.js</code> so you may need to handle the require and registration yourself.</p>
<p>Note, we may fail to correctly rewrite your <code>index.js</code>. You may need to write in the require and registration, but we&apos;ll provide the code you need.</p>
</blockquote><p><strong>Arguments</strong></p><ul>
<li><code>type [{resource,trigger,search,create}]</code> -- <strong>required</strong>, what type of thing are you creating</li>
<li><code>name [&quot;Some Name&quot;]</code> -- <strong>required</strong>, the name of the new thing to create</li>
<li><code>--dest={type}s/{name}</code> -- <em>optional</em>, sets the new file&apos;s path. Default is <code>{type}s/{name}</code></li>
<li><code>--entry=index.js</code> -- <em>optional</em>, where to import the new file. Default is <code>index.js</code></li>
<li>(required) <code>type</code> | undefined</li>
<li>(required) <code>name</code> | undefined</li>
</ul><p><strong>Flags</strong></p><ul>
<li><code>-d, --dest</code> | Sets the new file&apos;s path. Use this flag when you want to create a different folder structure such as <code>src/triggers/my_trigger</code> The default destination is {type}s/{name}</li>
<li><code>-e, --entry</code> | Where to import the new file Defaults to <code>index.js</code>.</li>
<li><code>-f, --force</code> | Should we overwrite an exisiting file</li>
<li><code>-d, --debug</code> | Show extra debugging output</li>
</ul><p><strong>Examples</strong></p><ul>
<li><code>zapier scaffold resource &quot;Contact&quot;</code></li>
<li><code>zapier scaffold resource &quot;Contact&quot; --entry=index.js</code></li>
<li><code>zapier scaffold resource &quot;Contag Tag&quot; --dest=resources/tag</code></li>
<li><code>zapier scaffold trigger &quot;Existing Create&quot; --force</code></li>
</ul>
</div>
<div class="col-md-7 col-sm-12 col-height docs-code">
<pre><code class="lang-bash">$ zapier scaffold resource <span class="hljs-string">&quot;Contact&quot;</span>
$ zapier scaffold resource <span class="hljs-string">&quot;Contact&quot;</span> --entry=index.js
$ zapier scaffold resource <span class="hljs-string">&quot;Contag Tag&quot;</span> --dest=resources/tag
$ zapier scaffold resource <span class="hljs-string">&quot;Tag&quot;</span> --entry=index.js --dest=resources/tag
<span class="hljs-comment"># Adding resource scaffold to your project.</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># Writing new resources/tag.js - done!</span>
<span class="hljs-comment"># Rewriting your index.js - done!</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># Finished! We did the best we could, you might gut check your files though.</span>
</code></pre>
<div class="col-md-7 col-sm-12 col-height is-empty docs-code">

</div>
</div>
</div><div class="row">
Expand Down
38 changes: 18 additions & 20 deletions packages/cli/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,39 +704,37 @@ $ zapier register "Example"

## scaffold

> Adds a starting resource, trigger, action or search to your app.
> Adds a starting resource, trigger, action or search to your app.

**Usage:** `zapier scaffold {resource|trigger|search|create} "Name"`
**Usage**: `zapier scaffold TYPE NAME`

The first argument should one of `resource|trigger|search|create` followed by the name of the file.


The scaffold command does two general things:

* Creates a new destination file like `resources/contact.js`

* (Attempts to) import and register it inside your entry `index.js`

You can mix and match several options to customize the created scaffold for your project.

> Note, we may fail to rewrite your `index.js` so you may need to handle the require and registration yourself.
> Note, we may fail to correctly rewrite your `index.js`. You may need to write in the require and registration, but we'll provide the code you need.

**Arguments**
* (required) `type` | undefined
* (required) `name` | undefined

* `type [{resource,trigger,search,create}]` -- **required**, what type of thing are you creating
* `name ["Some Name"]` -- **required**, the name of the new thing to create
* `--dest={type}s/{name}` -- _optional_, sets the new file's path. Default is `{type}s/{name}`
* `--entry=index.js` -- _optional_, where to import the new file. Default is `index.js`
**Flags**
* `-d, --dest` | Sets the new file's path. Use this flag when you want to create a different folder structure such as `src/triggers/my_trigger` The default destination is {type}s/{name}
* `-e, --entry` | Where to import the new file Defaults to `index.js`.
* `-f, --force` | Should we overwrite an exisiting file
* `-d, --debug` | Show extra debugging output

```bash
$ zapier scaffold resource "Contact"
$ zapier scaffold resource "Contact" --entry=index.js
$ zapier scaffold resource "Contag Tag" --dest=resources/tag
$ zapier scaffold resource "Tag" --entry=index.js --dest=resources/tag
# Adding resource scaffold to your project.
#
# Writing new resources/tag.js - done!
# Rewriting your index.js - done!
#
# Finished! We did the best we could, you might gut check your files though.
```
**Examples**
* `zapier scaffold resource "Contact"`
* `zapier scaffold resource "Contact" --entry=index.js`
* `zapier scaffold resource "Contag Tag" --dest=resources/tag`
* `zapier scaffold trigger "Existing Create" --force`


## test
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = {
logs: require('./logs'),
push: require('./push'),
register: require('./register'),
scaffold: require('./scaffold'),
upload: require('./upload'),
watch: require('./watch')
};
Loading