Skip to content

Commit

Permalink
Merge pull request #220 from oclif/mdonnalley/update-bin-refs
Browse files Browse the repository at this point in the history
fix: update bin script references
  • Loading branch information
mdonnalley authored Nov 22, 2023
2 parents d8d6fbf + 2070e0a commit 2356a96
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 105 deletions.
6 changes: 3 additions & 3 deletions docs/aliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ Creating a CLI that responds to different names or "aliases" is easy, simply add
"name": "mycli",
"version": "0.0.0",
"description": "My CLI",
"main": "bin/run",
"main": "bin/run.js",
"bin": {
"mycli": "./bin/run",
"mycli-alias": "./bin/run"
"mycli": "./bin/run.js",
"mycli-alias": "./bin/run.js"
},
"oclif": {
"binAliases": ["mycli", "mycli-alias"]
Expand Down
4 changes: 2 additions & 2 deletions docs/error_handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export default class Hello extends Command {

If this type of error handling is being implemented across multiple commands consider using a Custom Base Class (https://oclif.io/docs/base_class#docsNav) for your commands and overriding the `catch` method.

## bin/run `catch` handler
## bin/run.js `catch` handler

Every oclif CLI has a ./bin/run file that is the entry point of command invocation. Errors that occur in the CLI, including re-thrown errors from a Command, are caught here in the bin/run `catch` handler.
Every oclif CLI has a ./bin/run.js file that is the entry point of command invocation. Errors that occur in the CLI, including re-thrown errors from a Command, are caught here in the bin/run.js `catch` handler.

```js
.catch(require('@oclif/core/handle'))
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Creating a CLI:
$ npx oclif generate mynewcli
? npm package name (mynewcli): mynewcli
$ cd mynewcli
$ ./bin/dev hello world
$ ./bin/dev.js hello world
hello world! (./src/commands/hello/world.ts)
```
10 changes: 5 additions & 5 deletions docs/nsis-installer_customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
title: NSIS Installer Customization
---

Sometimes you need to verify some dependencies, ensure there are no conflicting CLIs installed, or do some other custom logic before installing your CLI. For npm-scenarios, simply specify a `preinstall` script. But Windows installers don't include this script. You must instead write your own nsis modification to do these checks. See where this custom script gets placed in the installer in the [oclif/oclif](https://github.com/oclif/oclif/blob/b8d76af9290716ef69d8d1026f98041268306dfd/src/commands/pack/win.ts#L60) repo.
Sometimes you need to verify some dependencies, ensure there are no conflicting CLIs installed, or do some other custom logic before installing your CLI. For npm-scenarios, simply specify a `preinstall` script. But Windows installers don't include this script. You must instead write your own nsis modification to do these checks. See where this custom script gets placed in the installer in the [oclif/oclif](https://github.com/oclif/oclif/blob/b8d76af9290716ef69d8d1026f98041268306dfd/src/commands/pack/win.ts#L60) repo.

See how [Salesforce CLI](https://github.com/salesforcecli/cli) did this to prevent their new major version being installed on top of an older, and incompatible, version. In that `package.json`, they specified an nsis installer like this:
See how [Salesforce CLI](https://github.com/salesforcecli/cli) did this to prevent their new major version being installed on top of an older, and incompatible, version. In that `package.json`, they specified an nsis installer like this:
```json

{
"name": "mycli",
"version": "0.0.0",
"description": "My CLI",
"main": "bin/run",
"bin": "./bin/run",
"main": "bin/run.js",
"bin": "./bin/run.js",
"oclif": {
"nsisCustomization": "scripts/nsis.nsi"
}
}
```

And then their custom script was loaded into the installer during the packing phase of the CLI.
And then their custom script was loaded into the installer during the packing phase of the CLI.
291 changes: 197 additions & 94 deletions website/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,121 +1,224 @@
import Layout from '@theme/Layout';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import React from 'react';
import Layout from "@theme/Layout";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import React from "react";

import {useColorMode} from '@docusaurus/theme-common';
import { useColorMode } from "@docusaurus/theme-common";

function docUrl(doc, language) {
const {siteConfig} = useDocusaurusContext();
return siteConfig.baseUrl + 'docs/' + (language ? language + '/' : '') + doc;
const { siteConfig } = useDocusaurusContext();
return siteConfig.baseUrl + "docs/" + (language ? language + "/" : "") + doc;
}

function toTitleCase(str) {
return str.split(' ')
.map(w => w[0].toUpperCase() + w.substring(1).toLowerCase())
.join(' ');
return str
.split(" ")
.map((w) => w[0].toUpperCase() + w.substring(1).toLowerCase())
.join(" ");
}

const ImageSwitcher = ({lightImageSrc, darkImageSrc, width, className}) => {
const ImageSwitcher = ({ lightImageSrc, darkImageSrc, width, className }) => {
return (
<img width={width ?? 512}
className={className ?? 'center'}
src={useColorMode().colorMode === 'dark' ? darkImageSrc : lightImageSrc}
alt='oclif'/>
)
}
<img
width={width ?? 512}
className={className ?? "center"}
src={useColorMode().colorMode === "dark" ? darkImageSrc : lightImageSrc}
alt="oclif"
/>
);
};

const Example = () => {
return (
<pre className={useColorMode().colorMode === 'dark' ? 'get-started-example-dark' : 'get-started-example'}>
<code>
<span className='block'><span className='opacity--60'>$</span> npx oclif generate mynewcli</span>
<span className='block padding-bottom--sm opacity--60'>? npm package name (mynewcli): mynewcli</span>
<span className='block padding-bottom--sm'><span className='opacity--60'>$</span> cd mynewcli</span>
<span className='block'><span className='opacity--60'>$</span> ./bin/run hello world</span>
<span className='block opacity--60'>hello world! (./src/commands/hello/world.ts)</span>
</code>
</pre>
)
}
<pre
className={
useColorMode().colorMode === "dark"
? "get-started-example-dark"
: "get-started-example"
}
>
<code>
<span className="block">
<span className="opacity--60">$</span> npx oclif generate mynewcli
</span>
<span className="block padding-bottom--sm opacity--60">
? npm package name (mynewcli): mynewcli
</span>
<span className="block padding-bottom--sm">
<span className="opacity--60">$</span> cd mynewcli
</span>
<span className="block">
<span className="opacity--60">$</span> ./bin/run.js hello world
</span>
<span className="block opacity--60">
hello world! (./src/commands/hello/world.ts)
</span>
</code>
</pre>
);
};

const CompanyLogo = ({width, viewBox, href, company}) => {
const alt = `${toTitleCase(company)} CLI`
const src = `img/${company}-logo.svg`
const CompanyLogo = ({ width, viewBox, href, company }) => {
const alt = `${toTitleCase(company)} CLI`;
const src = `img/${company}-logo.svg`;
return (
<a href={href} className='company-logo' target='_blank'>
<img alt={alt} src={src} width={width} viewBox={viewBox}/>
<a href={href} className="company-logo" target="_blank">
<img alt={alt} src={src} width={width} viewBox={viewBox} />
</a>
)
}
);
};

export default (props) => {
return <Layout>
<div>
<main className='homepage page-content' aria-label='Content'>
<section className='hero'>
<div className='container'>
<ImageSwitcher lightImageSrc={'img/oclif.svg'} darkImageSrc={'img/oclif_rev.svg'}/>
<h1 className='hero__title center code-font padding-vert--lg'>The Open CLI Framework</h1>
<h2 className='hero__subtitle center'>Create command line tools your users love</h2>
<div className='row'>
<div className='col col--6 col--offset-3'>
<p className='center'>oclif is an open source framework for building a command line interface (CLI) in Node.js and Typescript. Create CLIs with a few flags or advanced CLIs that have subcommands. oclif makes it easy for you to build CLIs for your company, service, or your own&nbsp;development&nbsp;needs.</p>
return (
<Layout>
<div>
<main className="homepage page-content" aria-label="Content">
<section className="hero">
<div className="container">
<ImageSwitcher
lightImageSrc={"img/oclif.svg"}
darkImageSrc={"img/oclif_rev.svg"}
/>
<h1 className="hero__title center code-font padding-vert--lg">
The Open CLI Framework
</h1>
<h2 className="hero__subtitle center">
Create command line tools your users love
</h2>
<div className="row">
<div className="col col--6 col--offset-3">
<p className="center">
oclif is an open source framework for building a command
line interface (CLI) in Node.js and Typescript. Create CLIs
with a few flags or advanced CLIs that have subcommands.
oclif makes it easy for you to build CLIs for your company,
service, or your own&nbsp;development&nbsp;needs.
</p>
</div>
</div>
</div>
<div className='row'>
<div className='center'>
<Example/>
<a className='button button--info button--lg shadow--tl' href={docUrl('introduction.html', props.language)}>
Get Started →
</a>
<div className="row">
<div className="center">
<Example />
<a
className="button button--info button--lg shadow--tl"
href={docUrl("introduction.html", props.language)}
>
Get Started →
</a>
</div>
</div>
</div>
</div>
</section>
<section className='hero padding--sm'>
<div className='container top-border'>
<div className='row'>
<div className='col col--3'>
<h2><span className='margin-right--xs'></span>Ready to go</h2>
<p>Scaffold a fully functional CLI to get started quickly. oclif packages our years of experience into out-of-the-box functionality for argument parsing, command testing, and auto-documentation of CLI&nbsp;features.</p>
</div>
<div className='col col--3'>
<h2><span className='margin-right--xs'>👐</span>Open source</h2>
<p>oclif is <a href='https://github.com/oclif/oclif/blob/main/LICENSE'>open source</a> and free to use or modify. We think you’ll love it too and you can also help make it&nbsp;better.</p>
</div>
<div className='col col--3'>
<h2><span className='margin-right--xs'></span>Extendable</h2>
<p>You or your users can easily extend your CLI functionality to meet custom needs using plugins. Plugins are modular and shareable, encouraging&nbsp;reuse.</p>
</div>
<div className='col col--3'>
<h2><span className='margin-right--xs'>🔒</span>Trusted</h2>
<p>oclif is actively used to build the <a href='https://github.com/heroku/cli' className='dim mid-gray'>Heroku</a> and <a href='https://developer.salesforce.com/tools/sfdxcli' className='dim mid-gray'>Salesforce CLIs</a>, powering millions of interactions for developers&nbsp;every&nbsp;day.</p>
</section>
<section className="hero padding--sm">
<div className="container top-border">
<div className="row">
<div className="col col--3">
<h2>
<span className="margin-right--xs"></span>Ready to go
</h2>
<p>
Scaffold a fully functional CLI to get started quickly.
oclif packages our years of experience into out-of-the-box
functionality for argument parsing, command testing, and
auto-documentation of CLI&nbsp;features.
</p>
</div>
<div className="col col--3">
<h2>
<span className="margin-right--xs">👐</span>Open source
</h2>
<p>
oclif is{" "}
<a href="https://github.com/oclif/oclif/blob/main/LICENSE">
open source
</a>{" "}
and free to use or modify. We think you’ll love it too and
you can also help make it&nbsp;better.
</p>
</div>
<div className="col col--3">
<h2>
<span className="margin-right--xs"></span>Extendable
</h2>
<p>
You or your users can easily extend your CLI functionality
to meet custom needs using plugins. Plugins are modular and
shareable, encouraging&nbsp;reuse.
</p>
</div>
<div className="col col--3">
<h2>
<span className="margin-right--xs">🔒</span>Trusted
</h2>
<p>
oclif is actively used to build the{" "}
<a
href="https://github.com/heroku/cli"
className="dim mid-gray"
>
Heroku
</a>{" "}
and{" "}
<a
href="https://developer.salesforce.com/tools/sfdxcli"
className="dim mid-gray"
>
Salesforce CLIs
</a>
, powering millions of interactions for
developers&nbsp;every&nbsp;day.
</p>
</div>
</div>
</div>
</div>
</section>
</section>

<section className='hero padding--sm'>
<div className='container top-border'>
<div className='row'>
<div className='col col--6 col--offset-3'>
<span className='center'>
<h2 className='hero__subtitle'>CLIs built using <ImageSwitcher lightImageSrc={'img/oclif.svg'} darkImageSrc={'img/oclif_rev.svg'} className='margin-left--xs inline-block' width={128}/></h2>
<p>With oclif you can build command line tools for your business, open source project, or your own development workflow. Check out what others have built.</p>
</span>
<section className="hero padding--sm">
<div className="container top-border">
<div className="row">
<div className="col col--6 col--offset-3">
<span className="center">
<h2 className="hero__subtitle">
CLIs built using{" "}
<ImageSwitcher
lightImageSrc={"img/oclif.svg"}
darkImageSrc={"img/oclif_rev.svg"}
className="margin-left--xs inline-block"
width={128}
/>
</h2>
<p>
With oclif you can build command line tools for your
business, open source project, or your own development
workflow. Check out what others have built.
</p>
</span>
</div>
</div>
</div>
<div className='row'>
<div className='company-container center'>
<CompanyLogo company='salesforce' href='https://github.com/salesforcecli/cli' width='96' viewBox='16 16 0 0'/>
<CompanyLogo company='heroku' href='https://github.com/heroku/cli' width='96' viewBox='16 16 0 0'/>
<CompanyLogo company='twilio' href='https://twilio.com/cli'/>
<CompanyLogo company='shopify' href='https://shopify.dev/apps/tools/cli'/>
<div className="row">
<div className="company-container center">
<CompanyLogo
company="salesforce"
href="https://github.com/salesforcecli/cli"
width="96"
viewBox="16 16 0 0"
/>
<CompanyLogo
company="heroku"
href="https://github.com/heroku/cli"
width="96"
viewBox="16 16 0 0"
/>
<CompanyLogo company="twilio" href="https://twilio.com/cli" />
<CompanyLogo
company="shopify"
href="https://shopify.dev/apps/tools/cli"
/>
</div>
</div>
</div>
</div>
</section>
</main>
</div>
</Layout>;
</section>
</main>
</div>
</Layout>
);
};

0 comments on commit 2356a96

Please sign in to comment.